Possible to link my static library with a dynamic library in Xcode?
I am currently creating a static library that contains functionality I want to provide to some other applications. However, my static library requi开发者_如何转开发res libxml2.dylib and compiling my static library fails at the moment because it's having trouble accessing the dylib. Is there a way to link my static lib with a dynamic lib?
Yes, this is possible. However, the resulting static library will have a run-time dependency to libxml2
. Notice that you will have to specify the location of the dynamic library at linktime using the -L
switch. Assuming you have installed libxml2
using MacPorts the path is /opt/local/lib
.
g++ -staticlib -o libyourlib.a file1.o file2.o -L/opt/local/lib -lxml2
精彩评论