I'm trying to create a .so on mac osx. There seems to be a distinction between .so and .dylib types.
$ file some_real.so
some_real.so: Mach-O 64-bit bundle x86_64
dynamiclib flag produces a dylib as expected
$ g++ -dynamiclib -o libgtest-1.7.0.dylib [my .o files]
$ file libgtest-1.7.0.dylib
libgtest-1.7.0.dylib: Mach-O 64-bit dynamically linked shared library x86_64
#### ^^^ as expected
shared flag is not giving what I want
$ g++ -shared -o libgtest-1.7.0.so [my .o files]
$ file libgtest-1.7.0.so
libgtest-1.7.0.dylib: Mach-O 64-bit dynamically linked shared library x86_64
#### ^^^ not as expected; wanted bundle x86_64
This stackoverflow answer talks about it a bit, and mentions the -fPIC flag. I added that to the commandline and it still produces a dynlib
$ g++ -shared -fPIC -o libgtest-1.7.0.so [my .o files]
$ file libgtest-1.7.0.so
libgtest-1.7.0.dylib: Mach-O 64-bit dynamically linked shared library x86_64
#### ^^^ not as expected; wanted bundle x86_64
(Why: I need this output to be of the .so/MH_BUNDLE type because I'm trying to create some google tests against something that is already in the .so format and the linker is refusing to link the gtest .dylib and my .so. )