QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1877|回复: 1

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

[复制链接]
发表于 2010-8-6 17:29:41 | 显示全部楼层 |阅读模式
g++ -o xmltest xmltest.cpp tinyxml.cpp tinystr.cpp tinyxmlerror.cpp tinyxmlparser.cpp
编译可以成功

但是做成静态库   ar cr tiny.a  tinyxml.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:perator+=(char const*)':
xmltest.cpp.text._ZN11TiXmlStringpLEPKc[TiXmlString:perator+=(char const*)]+0x23): undefined reference to `TiXmlString::append(char const*, unsigned int)'
/tmp/cceTNVUr.o: In function `TiXmlString:perator+=(TiXmlString const&)':
xmltest.cpp.text._ZN11TiXmlStringpLERKS_[TiXmlString:perator+=(TiXmlString const&)]+0x2e): undefined reference to `TiXmlString::append(char const*, unsigned int)'
/tmp/cceTNVUr.o: In function `TiXmlString:perator=(char const*)':
xmltest.cpp.text._ZN11TiXmlStringaSEPKc[TiXmlString:perator=(char const*)]+0x23): undefined reference to `TiXmlString::assign(char const*, unsigned int)'
/tmp/cceTNVUr.o: In function `TiXmlString:perator=(TiXmlString const&)':
xmltest.cpp.text._ZN11TiXmlStringaSERKS_[TiXmlString:perator=(TiXmlString const&)]+0x2e): undefined reference to `TiXmlString::assign(char const*, unsigned int)'
collect2: ld 返回 1
发表于 2011-2-13 22:29:09 | 显示全部楼层
先把xxxtest.cpp编译成.o
然后把.o和.a链接在一起
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-26 22:54 , Processed in 0.204093 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表