0

I have a c++ project that references the .h and .cpp files from the (ACE_TAO) library. (http://www.theaceorb.com/)

I have included the library paths to the project GCC C++ compiler and GCC C++ Linker.

However, when I try to build my project, I keep getting an error.

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

Here's my own project header file

#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 error

1) I have included the right header file and eclipse is able to to resolve the header file, so this must mean that my library paths is correct right?

2) If my library paths are correct, why is eclipse unable to link to the .cpp files for the implementation of the 2 methods? my .h file and .cpp files are in the same folder directory.

3) I thought that it could be because I do not have the .o files in the library paths, so i ran 'make' and generated the .o files in the same directory, but I still get the same error.

Am I missing/misunderstanding something? Thanks in advance.

update: Here's the command Eclipse c++ used to build my project

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();
Tony Tony
  • 455
  • 1
  • 4
  • 9

1 Answers1

0

The linking is failing. No, your "include" path determines whether you can find a header file. The "library" path is used for linking against the object files or the library files. The linking is not working.

The missing functions are the destructors for the classes ACE_Message_Block and ORB. Find the source files for them, compile them, and make sure the compiled object files are on the library path for your project.

Sean F
  • 4,344
  • 16
  • 30
  • I have compiled the source files in /home/user/Documents/ACE_wrappers/ace/ and /home/user/Documents/ACE_wrappers/Tao/tao/, and I have added both to my library path. I see .o objects for ACE_Message_Block and ORB. But I still received the same error – Tony Tony Nov 03 '16 at 06:47
  • Also check that you have specified the libraries on the command line. See here: http://stackoverflow.com/questions/22426574/gcc-undefined-reference-to . If you do not specify libraries by name and path, then ensure the library itself, full path, is included on the command line as well (any .o files). In addition, I might consider looking at the the two .inl files that are triggering the issue. If your linking settings are correct, then it may be a namespace issue, in which case the namespace being used to search for the class does not match the correct namespace. – Sean F Nov 03 '16 at 15:13
  • Maybe you should post your gcc command lines, there will be either one big command line or multiple compile and/or link command lines. – Sean F Nov 03 '16 at 15:27
  • my command is "g++ -L/home/user/Documents/ACE_wrappers/ -L/home/user/Documents/ACE_wrappers/TAO/ -L/home/user/Documents/ACE_wrappers/ace/ -o "TAOServer" ./MyServer.o – Tony Tony Nov 04 '16 at 02:04
  • When compiling and linking with gcc or any other compiler of c++ or c, there are a few elements to the command line. There are the things you are compiling in your command, those are the c++/cpp/c files. Then there are the things you are linking against, those are the .o object files and the libs specifed by -l (the L is lowercase). – Sean F Nov 04 '16 at 02:30
  • All you have there is the MyServer.o file. That is presumably the an object file that was compiled by a previous incarnation of gcc on MyServer.cpp. There's nothing on that command line for the things you are linking against, that is why the linker cannot find those things. You need to either (a) compile the ace/orb c/cpp sources files into .o files and include them on the above command line or (b) compile them into a .lib file and link against it with -l on the above command line or (c) use the precompiled lib or object files (d) include all those cpp files on the command line – Sean F Nov 04 '16 at 02:31
  • Here is a link explaining how to compile and link: https://courses.cs.washington.edu/courses/cse326/02wi/unix/g++.html That link explains how to link against object files and/or libraries. One way or the other you need to link against those ace and orb classes and functions. – Sean F Nov 04 '16 at 02:32
  • I realise that I missed out some commands. I have updated my question on the commands eclipse c++ used to build my project. I have taken a look at the link you have given, but since I am using Eclipse c++ to build my project, shouldn't I rely on the auto generated build script instead? – Tony Tony Nov 04 '16 at 03:15
  • Yes you should but in the end Eclipse will run commands similar to the ones listed in that link. Even though you updated the commands, my comment is the same: the final command is not linking against the ace and orb classes. You must have the object files, libraries, or source files from that library on the command line. You need to update your Eclipse workspace to do that. – Sean F Nov 04 '16 at 03:31