我有一个c++项目,它从(ACE_TAO)库引用.h和.cpp文件。(http://www.theaceorb.com/)
我已经包括了项目GCC,C++编译器和GCC C++链接器的库路径。
然而,当我试图构建我的项目时,我总是会遇到一个错误。
undefined reference to ACE_Message_Block::~ACE_Message_Block()
| line 627 external location /home/user/Documents/ACE_wrappers/ace/CDR_Stream.inl
undefined reference to CORBA::ORB~ORB();
| line 45 external location /home/user/Documents/ACE_wrappers/Tao/tao/ORB.inl这是我自己的项目头文件
#ifndef MESSENGERSERVER_H_
#define MESSENGERSERVER_H_
#include <tao/ORB.h> // this is causing the error
class MessengerServer {
public:
MessengerServer();
virtual ~MessengerServer();
private:
CORBA::ORB_var orb; // this is causing the error1)我包含了正确的头文件,eclipse能够解析头文件,所以这一定意味着我的库路径是正确的,对吗?
2)如果我的库路径是正确的,为什么eclipse不能链接到.cpp文件以实现这两个方法?我的.h文件和.cpp文件位于同一个文件夹目录中。
3)我认为这可能是因为库路径中没有.o文件,所以我运行了“make”并在同一个目录中生成了.o文件,但仍然得到了相同的错误。
我是不是错过了什么/误会了?提前谢谢。
更新:下面是用于构建我的项目的命令c++
g++ -I/home/user/Documents/ACE_wrappers/TAO/
-I/home/user/Documents/ACE_wrappers/ace/
-I/home/user/Documents/ACE_wrappers/
-O0- g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"myMain.d" -MT"myMain.d" -o"myMain.o" "../myMain.cpp"
Finished Building:../MyMain.cpp
g++ -I/home/user/Documents/ACE_wrappers/TAO/
-I/home/user/Documents/ACE_wrappers/ace/
-I/home/user/Documents/ACE_wrappers/
-O0- g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"MyServer.d" -MT"MyServer.d" -o"MyServer.o" "../MyServer.cpp"
Finished Building:../MyServer.cpp
g++ -L/home/user/Documents/ACE_wrappers/TAO/
-L/home/user/Documents/ACE_wrappers/ace/
-L/home/user/Documents/ACE_wrappers/
-o "TAOServer" ./myMain.o ./MyServer.o
./MyMain.o: In function 'ACE_InputCDR:~ACE_InputCDR()':
/home/user/Documents/ACE_wrappers/ace/CDR_Stream.inl:627: undefined reference to ACE_Message_Block::~ACE_Message_Block()
./MyServer.o: In function 'CORBA::ORB:decr_refcount()':
/home/user/Documents/ACE_wrappers/Tao/tao/ORB.inl:45: undefined reference to CORBA::ORB~ORB();发布于 2016-11-03 05:48:42
连接失败了。否,您的“包括”路径决定您是否可以找到一个头文件。“库”路径用于针对对象文件或库文件进行链接。连接不起作用。
缺少的函数是类ACE_Message_Block和ORB的析构函数。为它们查找源文件,编译它们,并确保编译的对象文件位于项目的库路径上。
https://stackoverflow.com/questions/40393499
复制相似问题