Clang and undefined symbols when building a library

后端 未结 3 1596
一整个雨季
一整个雨季 2020-12-08 17:17

I\'m working on a C++ framework, and there\'s a few issues when I compile it on OSX with Clang.

First of, I\'m using some other libraries, such as openssl, and clang

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 17:21

    I don't recommend to enable global dynamic lookup:

    -undefined dynamic_lookup which will mark all undefined symbols as having to be looked up at runtime.

    Much more safe way to resolve it for specific symbols:

    -Wl,-U,symbol_name, which only does so for the given symbol (note: you have to prepend an underscore to the symbol name)

    You could also use weak dynamic linking:

    extern int SayHello() __attribute__((weak));
    

提交回复
热议问题