C++ 将库静态链接到C++;OSX上的动态库

C++ 将库静态链接到C++;OSX上的动态库,c++,macos,static-linking,dylib,C++,Macos,Static Linking,Dylib,我正在编译大量的.dylibs(一个插件),我想静态地将tinyxml2包含在其中。 我有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.

我正在编译大量的.dylibs(一个插件),我想静态地将tinyxml2包含在其中。 我有
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
我应该如何进行链接?(我希望我正在构建的所有.dylib静态地包括tinyxml2库,最好是名称空间混乱)


请注意,我在这里使用的是较旧的10.5 SDK-我必须这样做,因为我的主机应用程序使用它。

链接时,您将指定所需的所有对象文件。因此,当链接到创建
SyGeo.dylib
时,在
SyGeo.os
之后添加
tinyxml2.a
当您创建SyGeo.dylib时,在
SyGeo.os
之后添加
!非常感谢!如果你把你的评论移到一个答案上,我会把它标记为接受。