Archived
This forum has been archived. Please start a new discussion on GitHub.
Problem compiling C++
Hi
I have been using Ice with Python for some time with good results. I now need a C++ node. I'm no doubt doing something stupid but would appreciate it if someone could put me straight.
I'm using Eclipse on Ubuntu 8.04. This is a very simple test node with a test interface just so I can get some comms going from my Python node to C++ node.
Here is the Ice def:
and here is the code.
Thanks
Bob
I have been using Ice with Python for some time with good results. I now need a C++ node. I'm no doubt doing something stupid but would appreciate it if someone could put me straight.
I'm using Eclipse on Ubuntu 8.04. This is a very simple test node with a test interface just so I can get some comms going from my Python node to C++ node.
Here is the Ice def:
#ifndef DISPLAYS_ICE #define DISPLAYS_ICE module AcornDisplays { interface Displays { void data(string display); }; }; #endif
and here is the code.
#include <Ice/Ice.h> #include <IceStorm/IceStorm.h> #include "displays.h" using namespace std; using namespace AcornDisplays; class DisplaysI : virtual public Displays { public: virtual void data(const string& s, const Ice::Current&); }; void DisplaysI::data(const string& s, const Ice::Current&) { cout << "Got some data!"; } int main(int argc, char* argv[]) { int status = 0; Ice::CommunicatorPtr ic; IceStorm::TopicManagerPrx topicManager; Ice::ObjectPrx proxy; Ice::ObjectAdapterPtr adapter; IceStorm::TopicPrx topic; try { ic = Ice::initialize(argc, argv); Ice::ObjectPrx obj = ic->propertyToProxy("TopicManager.Proxy"); topicManager = IceStorm::TopicManagerPrx::checkedCast(obj); adapter = ic->createObjectAdapter("Display.Subscriber"); DisplaysPtr display = new DisplaysI; proxy = adapter->addWithUUID(display)->ice_oneway(); } catch (const Ice::Exception& e) { cerr << e << endl; status = 1; } try { topic = topicManager->retrieve("Display"); IceStorm::QoS qos; topic->subscribeAndGetPublisher(qos, proxy); } catch (const IceStorm::NoSuchTopic&) { cout << "Error! No topic found!"; exit(1); } try { adapter->activate(); } catch (const Ice::Exception& e) { cerr << e << endl; status = 1; } ic->waitForShutdown(); topic->unsubscribe(proxy); return status; }I am linking with Ice, IceUtil and IceStorm. I am getting the following link errors which I don't understand.
/home/bob/dev/projects/acorn-sdr/ice/displays.h undefined reference to `vtable for AcornDisplays::Displays' displays /home/bob/dev/projects/acorn-sdr/ice/displays.h undefined reference to `VTT for AcornDisplays::Displays' displays /opt/Ice-3.3.0/include/Ice/Handle.h undefined reference to `IceInternal::upCast(AcornDisplays::Displays*)' displays /opt/Ice-3.3.0/include/Ice/Handle.h undefined reference to `IceInternal::upCast(AcornDisplays::Displays*)' displays
Thanks
Bob
0
Comments
-
It sounds like you are not compiling the generated .cpp file (displays.cpp?) or just not linking with the resultant object file if you are compiling it.0
-
Thanks for the prompt reply. As far as I can tell everything is compiled and linked. I tried it from the makefile rather than the IDE. I get a lot more errors so I have just given the first few.
bob@bob-desktop:~/dev/projects/acorn-sdr/src/displays/Release$ make Building file: ../display_main.cpp Invoking: GCC C++ Compiler g++ -I/home/bob/dev/projects/acorn-sdr/src/displays -I/home/bob/dev/projects/acorn-sdr/ice -I/opt/Ice-3.3.0/include -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"display_main.d" -MT"display_main.d" -o"display_main.o" "../display_main.cpp" Finished building: ../display_main.cpp Building target: displays Invoking: GCC C++ Linker g++ -L/opt/Ice-3.3.0/lib -o"displays" ./display_main.o -lIce -lIceUtil -lIceStorm ./display_main.o: In function `main': display_main.cpp:(.text+0x425): undefined reference to `IceInternal::upCast(AcornDisplays::Displays*)' display_main.cpp:(.text+0x515): undefined reference to `IceInternal::upCast(AcornDisplays::Displays*)' display_main.cpp:(.text+0xb64): undefined reference to `IceInternal::upCast(AcornDisplays::Displays*)'
0 -
g++ -L/opt/Ice-3.3.0/lib -o"displays" ./display_main.o -lIce -lIceUtil -lIceStorm
Surely display.o (or whatever the name of the translated slice file is) is missing from that list.0 -
Of course it is. I was just blind and forgot about the auto-generated file. Sorry for the noise.0