質問

I'm trying to make dynamic lib from set of .o files, but when i do

gcc -dynamiclib -current_version 1.0 mymod.o -o mylib.dylib

or

ld *.o -o mylib.dylib

i get a lot of errors like:

"_objc_msgSend", referenced from: -[NSObject(NSObject_SBJSON) JSONFragment] in NSObject+SBJSON.o

"operator new(unsigned long)", referenced from: MStatistic::instance() in MStatistic.o StatisticProfileLoggingObserver::instance() in StatisticObserver.o

ld: symbol(s) not found for architecture x86_64

Can you please help me, how to solve it and get my .dylib?

役に立ちましたか?

解決

You can pass -undefined dynamic_lookup as an option to ld, or:
-Wl,-undefined -Wl,dynamic_lookup to gcc or clang (which passes it to the linker).

他のヒント

From this line:

ld: symbol(s) not found for architecture x86_64

it sounds like you are building some libraries that have make files that only build for 32-bit architectures.

You need to modify the makefiles for all the libraries / frameworks you're building to build both 32-bit and 64-bit; and in a practical sense, all shipping MacOS machines are 64-bit capable so it may just be safe to build only for 64-bit.

In your compile / linking lines, add something like this: "-arch x86_64" and that should compile things for the 64-bit side. To do both 32 & 64-bit, you'll basically need to duplicate the compile & link lines with their own "-arch i386" and "-arch x86_64" lines.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top