35

I have several .o files and want to bundle them in a .dylib, how can I do that it Mac OS X using gcc? Thank you very much.

Tianyi Cui
  • 3,933
  • 3
  • 21
  • 18

1 Answers1

73

Use g++ -dynamiclib -undefined suppress -flat_namespace *.o -o something.dylib

Tianyi Cui
  • 3,933
  • 3
  • 21
  • 18
  • 6
    Note to anyone reading this in later years: The -flat_namespace option is no longer necessary. It was a compatibility hack introduced around OS 10.4 to make libraries built with 10.4+ tools to still work with pre-10.4 systems. On later systems, it can cause linking problems and should not be used. – Ross Smith Jul 06 '16 at 21:45