LinuxSir.cn,穿越时空的Linuxsir!

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

请问kdevelop的一个工程如何设置才能编译成共享库(.so文件)?

[复制链接]
发表于 2004-11-25 11:48:07 | 显示全部楼层 |阅读模式
多谢!
发表于 2004-11-25 11:52:00 | 显示全部楼层
先搜索论坛,有问题再来问。
 楼主| 发表于 2004-11-25 16:47:07 | 显示全部楼层
就是纯C++的代码,在kdevelop下编译是通过的,如何设置让它编译成一个共享库?我在论坛上找了找没找到?有谁知道的告诉一声!谢谢!
发表于 2004-11-25 17:03:06 | 显示全部楼层
怎么会找不到?编译动态库就那么几个选项。在程序设计版入口处的右下角可以输入对本版进行查询的内容。你用“动态库”作为关键字搜索看看。然后自己根据这个去修改一下makefile就应该可以了。
 楼主| 发表于 2004-11-26 15:12:45 | 显示全部楼层
谢谢你的回贴,我知道用GCC的命令怎么将程序编译连接成动态库或静态库。我也按照你说的查了查论坛上的内容。
但是我有一个程序是从windows下移植到linux下的,程序有一些不兼容的地方我进行了改写,在kdevelop下Compile没有错误,但是make的时候最后一条命令执行时出错,程序有多个目录,我看到kdevelop在每个目录下都生成了一个makefile文件。而且每个目录下生成了一个lib**.a文件。执行的错误如下:
提示有undefined reference to ××××,但是这方法已经定义了,如果把这个方法的定义从.cpp文件拿到它声明的.h文件中就不会提示这个错误?是不是哪个选项没有设置好?刚用Kdevelop,请多执教!谢谢!!

/bin/sh ../libtool --silent --mode=link --tag=CXX g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -O2 -O0 -g3 -Wall -fpic -fno-exceptions -fno-check-new -fexceptions -lpthread -o lrc1 main.o RtiAmbServices.o ./bases/libbases.a ./LrcData/libLrcData.a ./cbMgr/libcbMgr.a ./clientIF/libclientIF.a ./init/libinit.a ./init/Parser/libParser.a ./LrcService/libLrcService.a ./kernel/libkernel.a ./serviceIF/libserviceIF.la ./NAL/libNAL.la
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x14): In function `DveSupportService:veSupportService[not-in-charge]()':
../LrcData/DveInteraction.h:140: undefined reference to `DveObjectHashList:veObjectHashList[in-charge](int)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x2a):../LrcData/DveInteraction.h:140: undefined reference to `DveInteractionHashList:veInteractionHashList[in-charge](int)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x5c):../LrcData/DveInteraction.h:140: undefined reference to `DveInteractionHashList::~DveInteractionHashList [in-charge]()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x79):../LrcData/DveInteraction.h:140: undefined reference to `DveObjectHashList::~DveObjectHashList [in-charge]()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0xa8): In function `DveSupportService:veSupportService[in-charge]()':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:39: undefined reference to `DveObjectHashList:veObjectHashList[in-charge](int)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0xbe):/root/lrc1/lrc1/LrcService/DveSupportService.cpp:39: undefined reference to `DveInteractionHashList:veInteractionHashList[in-charge](int)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0xf0):/root/lrc1/lrc1/LrcService/DveSupportService.cpp:39: undefined reference to `DveInteractionHashList::~DveInteractionHashList [in-charge]()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x10d):/root/lrc1/lrc1/LrcService/DveSupportService.cpp:39: undefined reference to `DveObjectHashList::~DveObjectHashList [in-charge]()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x15d): In function `DveSupportService::~DveSupportService [not-in-charge]()':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:46: undefined reference to `DveInteractionHashList::~DveInteractionHashList [in-charge]()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x16f):/root/lrc1/lrc1/LrcService/DveSupportService.cpp:46: undefined reference to `DveObjectHashList::~DveObjectHashList [in-charge]()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x1ad): In function `DveSupportService::~DveSupportService [in-charge]()':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:46: undefined reference to `DveInteractionHashList::~DveInteractionHashList [in-charge]()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x1bf):/root/lrc1/lrc1/LrcService/DveSupportService.cpp:46: undefined reference to `DveObjectHashList::~DveObjectHashList [in-charge]()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x1d9): In function `DveSupportService::removeAndDeleteAll()':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:51: undefined reference to `DveObjectHashList::removeAndDeleteAll()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x1ed):/root/lrc1/lrc1/LrcService/DveSupportService.cpp:52: undefined reference to `DveInteractionHashList::removeAndDeleteAll()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x281): In function `DveSupportService::readFed()':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:71: undefined reference to `DveReadFed(DveObjectHashList*, DveInteractionHashList*, DveRoutingSpaceHashList*, char const*)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x2b1): In function `DveSupportService::readFile()':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:75: undefined reference to `DveReadFile(DveObjectHashList*, DveInteractionHashList*, DveRoutingSpaceHashList*, char const*)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x2ce): In function `DveSupportService::getAttributeName(unsigned long, unsigned long)':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:84: undefined reference to `DveObjectHashList::lookup(unsigned long)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x35e): In function `DveSupportService::getInteractionClassName(unsigned long)':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:110: undefined reference to `DveInteractionHashList::lookup(unsigned long)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x3a2): In function `DveSupportService::getObjectClassName(unsigned long)':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:120: undefined reference to `DveObjectHashList::lookup(unsigned long)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x458): In function `DveSupportService::getParameterName(unsigned long, unsigned long)':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:160: undefined reference to `DveInteractionHashList::lookup(unsigned long)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x4e4): In function `DveSupportService::getAttributeRoutingSpaceHandle(unsigned long, unsigned long)':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:180: undefined reference to `DveObjectHashList::lookup(unsigned long)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x574): In function `DveSupportService::getInteractionRoutingSpaceHandle(unsigned long)':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:200: undefined reference to `DveInteractionHashList::lookup(unsigned long)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x58b):/root/lrc1/lrc1/LrcService/DveSupportService.cpp:203: undefined reference to `DveInteraction::getSpaceHandle()'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x67e): In function `DveSupportService::setInteractionOrderType(unsigned long, TransportationOrder)':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:237: undefined reference to `DveInteractionHashList::lookup(unsigned long)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x692):/root/lrc1/lrc1/LrcService/DveSupportService.cpp:238: undefined reference to `DveInteraction::setOrdering(TransportationOrder)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x6b2): In function `DveSupportService::isInteractionTSO(unsigned long)':
/root/lrc1/lrc1/LrcService/DveSupportService.cpp:243: undefined reference to `DveInteractionHashList::lookup(unsigned long)'
./LrcService/libLrcService.a(DveSupportService.o)(.text+0x6c3):/root/lrc1/lrc1/LrcService/DveSupportService.cpp:244: undefined reference to `DveInteraction::getOrdering()'
./LrcService/libLrcService.a(DveLocalService.o)(.text+0x11e7): In function `DveLocalService::getObjectClassHandle(char const*)':
/root/lrc1/lrc1/LrcService/DveLocalService.cpp:314: undefined reference to `DveObjectHashList::lookup(char const*)'
./LrcService/libLrcService.a(DveLocalService.o)(.text+0x1295): In function `DveLocalService::getInteractionClassHandle(char const*)':
/root/lrc1/lrc1/LrcService/DveLocalService.cpp:337: undefined reference to `DveInteractionHashList::lookup(char const*)'
./LrcService/libLrcService.a(DveLocalService.o)(.text+0x1303): In function `DveLocalService::getParameterHandle(char const*, unsigned long)':
/root/lrc1/lrc1/LrcService/DveLocalService.cpp:350: undefined reference to `DveInteraction::parameterHandle(char const*)'
./LrcService/libLrcService.a(DveLocalService.o)(.gnu.linkonce.t._ZN17DveSupportService22getAttributeLayerValueEmm+0x14): In function `DveSupportService::getAttributeLayerValue(unsigned long, unsigned long)':
../bases/DveRtiInterIF.h:1071: undefined reference to `DveObjectHashList::lookup(unsigned long)'
collect2: ld returned 1 exit gmake[3]: Leaving directory `/root/lrc1/lrc1'
gmake[2]: Leaving directory `/root/lrc1/lrc1'
gmake[1]: Leaving directory `/root/lrc1'
status
gmake[3]: *** [lrc1] Error 1
gmake[2]: *** [all-recursive] Error 1
gmake[1]: *** [all-recursive] Error 1
gmake: *** [all] Error 2
*** failed ***
发表于 2004-11-26 16:18:21 | 显示全部楼层
我从来没有用过kdevelop。不过,具体的编译工作是可以用autotools工作完成的。估计IDE生成的编译配置文件中路径可以有问题,找不到需要的文件。
你自己看看生成的配置文件吧。可以参考我在CU上的回答:
http://bbs.chinaunix.net/forum/v ... 3&show_type=new
 楼主| 发表于 2004-11-26 17:15:49 | 显示全部楼层
好的,谢谢kj501.我再看看!
 楼主| 发表于 2004-11-26 19:42:52 | 显示全部楼层
我看了你的帖子,很有帮助,非常感谢!
http://bbs.chinaunix.net/forum/view...p;show_type=new
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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