LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1509|回复: 5

g++ 怎么包含makefile,困惑不解,请高手指点迷津阿,急啊!

[复制链接]
发表于 2004-10-16 20:22:56 | 显示全部楼层 |阅读模式
我要编译一个开元的代码,我把所有要的库文件都加上了,但还是出现link错误,我发信问开元代码的开发人员,我给他发信的内容如下:
there is an another question about compiling /test/sample_server.cxx
using g++ manually.I have did what you told me,howerver,when I pass libdiameter.a as arguments to g++ like this -l/usr/local/lib/opendiameter/libdiameter.a,g++ told me that it can not find libdiameter.a,so I pass -L/usr/local/lib/opendiameter as
arguments to g++ instead ,some linking errors as following occured which show it can not find dependent libaries(libdiameter.a and libdiamparser.a),I am olso confused.

他给我的回答是:
The compile error your encountering has to do with NOT using the
makefiles. You have some mis-match symbol export because of this

我不明白他说的是什么意思,g++编译程序要用到makefile文件?怎么用阿?想不明白怎么回事,望大虾指点小弟我啊,项目原因,很急阿!小弟我先行谢过了!!
发表于 2004-10-16 20:57:12 | 显示全部楼层
他的意思是叫你写或利用软件原有的makefile执行make来自动编译。如果你是直接用g++加参数来编译的请帖出具体情况。
 楼主| 发表于 2004-10-18 11:50:44 | 显示全部楼层
我是想利用他的library开发自己的东西,那我该如何编译自己写的程序,总不能用他的makefile文件吧?我看了他的的makefile文件,基本上看懂了,不过不太好改。所以我想直接用g++编译他的sample,我们的程序就是按照sample的方式来写,所以的编译通过sample,但是在在编译的时候出现了link错误,我不知道如何解决。
我是这样编译他的sample的:
g++ -o server -g
-I/root/opendiameter/opendiameter-1.0.7/opendiameter-1.0.7-b/libdiameter/include
-I/root/opendiameter/opendiameter-1.0.7/opendiameter-1.0.7-b/libdiameter/test
-I/root/opendiameter/ACE/ACE_wrappers
-I/root/opendiameter/opendiameter-1.0.7/opendiameter-1.0.7-b/include
-I/root/opendiameter/opendiameter-1.0.7/opendiameter-1.0.7-b/libdiamparser
-I/root/opendiameter/ACE/ACE_wrappers/ace
-I/root/opendiameter/boost/boost-1.30.2/boost
-I/root/opendiameter/boost/boost-1.30.2/boost/function -L/usr/local/lib/opendiameter /root/opendiameter/opendiameter-1.0.7/opendiameter-1.0.7-b/libdiameter/test/sample
_server.cxx 2> /root/debug.txt

结果出现下列类似的错误:

/tmp/ccdYmPgS.o(.gnu.linkonce.d._ZTI28AAAServerSessionClassFactoryI25AAASampleAccountingServerE+0x8):/root/opendiameter/opendiameter-1.0.7/opendiameter-1.0.7-b/libdiameter/include/diameter_api.h:237: undefined reference to `typeinfo for AAAServerSessionFactory'

不知道如何解决这些问题,头文件我加了,要的库文件我也加了,但是还是出现link错误。
请各位大虾指点小弟哦,不胜感谢!
发表于 2004-10-18 16:03:42 | 显示全部楼层
编译时没有加上库文件。
 楼主| 发表于 2004-10-18 21:02:49 | 显示全部楼层
-L/usr/local/lib/opendiameter 这个参数就是加库文件的阿,而且,我还把它的库文件复制到/usr/lib里面去了,怎么还会说找不到库文件呢?
发表于 2004-10-18 22:03:09 | 显示全部楼层
最初由 batigolsg 发表
-L/usr/local/lib/opendiameter 这个参数就是加库文件的阿,而且,我还把它的库文件复制到/usr/lib里面去了,怎么还会说找不到库文件呢?

这个只是指定查找库文件的目录,而没有指定具体的库。
应该使用-lxxx
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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