2012-08-01 27 views
0

我正在編譯一些.dylibs(一個插件),我想靜態地將tinyxml2包含到它們中。 我有tinyxml2.cpptinyxml2.h坐在旁邊的來源。當我運行我的作品時,它生成的命令是:靜態鏈接庫到OSX上的C++ dylib

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庫,最好使用名稱空間修飾)。

請注意,我在這裏使用的是舊版本的10.5 SDK--因爲我的主機應用程序使用它。

+0

當您創建SyGeo.dylib時,在'SyGeo.os'後添加'tinyxml2.a'。 – 2012-08-01 17:53:49

+0

你的意思是在鏈接命令或編譯命令? – Julik 2012-08-01 17:57:25

+0

鏈接命令/第3個/創建「SyGeo.dylib」的命令。 – 2012-08-01 19:58:55

回答

1

鏈接時,您將指定所需的所有對象文件。因此在鏈接創建SyGeo.dylib時,在SyGeo.os之後添加tinyxml2.a