wjh19870407 发表于 2010-8-6 17:29:41

编译静态库问题 请大家帮忙解决一下

g++ -o xmltest xmltest.cpp tinyxml.cpp tinystr.cpp tinyxmlerror.cpp tinyxmlparser.cpp
编译可以成功

但是做成静态库   ar cr tiny.atinyxml.o tinystr.o tinyxmlerror.o tinyxmlparser.o

编译 g++ -o xmltest xmltest.cpp -L.-l tiny.a就报错了

都是这一系列这样的错误,列出一部分,都是 “undefined reference to ”的错误
/tmp/cceTNVUr.o: In function `TiXmlString::operator+=(char const*)':
xmltest.cpp:(.text._ZN11TiXmlStringpLEPKc+0x23): undefined reference to `TiXmlString::append(char const*, unsigned int)'
/tmp/cceTNVUr.o: In function `TiXmlString::operator+=(TiXmlString const&)':
xmltest.cpp:(.text._ZN11TiXmlStringpLERKS_+0x2e): undefined reference to `TiXmlString::append(char const*, unsigned int)'
/tmp/cceTNVUr.o: In function `TiXmlString::operator=(char const*)':
xmltest.cpp:(.text._ZN11TiXmlStringaSEPKc+0x23): undefined reference to `TiXmlString::assign(char const*, unsigned int)'
/tmp/cceTNVUr.o: In function `TiXmlString::operator=(TiXmlString const&)':
xmltest.cpp:(.text._ZN11TiXmlStringaSERKS_+0x2e): undefined reference to `TiXmlString::assign(char const*, unsigned int)'
collect2: ld 返回 1

默难 发表于 2011-2-13 22:29:09

先把xxxtest.cpp编译成.o
然后把.o和.a链接在一起
页: [1]
查看完整版本: 编译静态库问题 请大家帮忙解决一下