Error creating dynamic lib from .o

I am trying to make a dynamic lib from a 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, such as:

"_ objc_msgSend" referenced by: - ​​[NSObject (NSObject_SBJSON) JSONFragment] in NSObject + SBJSON.o

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

ld: characters (characters) not found for x86_64 architecture

Could you please help me how to solve this problem and get my .dylib?

0
source share
2 answers

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

+3
source

From this line:

 ld: symbol(s) not found for architecture x86_64 

it looks like you are creating several libraries that create files that are created only for 32-bit architectures.

You need to change the makefiles for all the libraries / frameworks you build to create 32-bit and 64-bit; and in a practical sense, all devices for delivering MacOS computers have 64-bit compatibility, so it can be safe to create for a 64-bit version .

In your compilation / linking lines add something like this: " -arch x86_64 " and this should compile things for the 64 bit side. To execute both 32 and 64-bit, you will mainly need to duplicate compilation lines and links with your lines " -arch i386 " and " -arch x86_64 ".

0
source

Source: https://habr.com/ru/post/974146/


All Articles