[英]Statically linking a library into a C++ dylib on OSX
我正在編譯許多.dylibs(一個插件),我想將tinyxml2靜態地包含在其中。 我在源代碼旁邊tinyxml2.h
了tinyxml2.cpp
和tinyxml2.h
。 當我運行make時,它生成的命令是:
rm -rf *.a *.os *.dylib
g++-4.0 -g -c -Werror -DUSE_GLEW -I/Applications/Nuke6.3v4/Nuke6.3v4.app/Contents/MacOS/include -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch x86_64 tinyxml2.cpp -o tinyxml2.a
g++-4.0 -g -c -Werror -DUSE_GLEW -I/Applications/Nuke6.3v4/Nuke6.3v4.app/Contents/MacOS/include -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch x86_64 -o SyGeo.os SyGeo.cpp
g++-4.0 -L/Applications/Nuke6.3v4/Nuke6.3v4.app/Contents/MacOS -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch x86_64 -bundle -lDDImage -lGLEW -framework QuartzCore -framework IOKit -framework CoreFoundation -framework Carbon -framework ApplicationServices -framework OpenGL -framework AGL -o SyGeo.dylib SyGeo.os
Undefined symbols:
"tinyxml2::XMLDocument::LoadFile(char const*)", referenced from:
SyDistorter::readPreset() in SyGeo.os
"tinyxml2::XMLDocument::~XMLDocument()", referenced from:
SyDistorter::readPreset() in SyGeo.os
SyDistorter::readPreset() in SyGeo.os
"tinyxml2::XMLElement::FindAttribute(char const*) const", referenced from:
tinyxml2::XMLElement::QueryFloatAttribute(char const*, float*) constin SyGeo.os
"tinyxml2::XMLNode::NextSiblingElement(char const*) const", referenced from:
tinyxml2::XMLNode::NextSiblingElement(char const*)in SyGeo.os
"tinyxml2::XMLDocument::XMLDocument(bool)", referenced from:
SyDistorter::readPreset() in SyGeo.os
"tinyxml2::XMLNode::FirstChildElement(char const*) const", referenced from:
tinyxml2::XMLNode::FirstChildElement(char const*)in SyGeo.os
"tinyxml2::XMLAttribute::QueryFloatValue(float*) const", referenced from:
tinyxml2::XMLElement::QueryFloatAttribute(char const*, float*) constin SyGeo.os
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [SyGeo.dylib] Error 1
我應該如何進行鏈接? (我希望構建的所有.dylibs都靜態地包含tinyxml2 lib,最好使用名稱空間修改)。
請注意,我在這里使用的是較舊的10.5 SDK-自從主機應用程序使用它以來,我就必須這樣做。
鏈接時,您將指定所有需要的目標文件。 所以加tinyxml2.a
后SyGeo.os
鏈接創建時SyGeo.dylib
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.