Results 1 to 5 of 5

Thread: Problem compiling C++

  1. #1
    bobc is offline Registered User
    Name: Bob Cowdery
    Organization: Personal
    Project: Software Radio
    Join Date
    Jan 2009
    Posts
    16

    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:

    Code:
    #ifndef DISPLAYS_ICE
    #define DISPLAYS_ICE
    
    module AcornDisplays
    {
        
        interface Displays
        {
            void data(string display);
        };
    
    };
    #endif
    and here is the code.

    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.

    Code:
    /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

  2. #2
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    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.

  3. #3
    bobc is offline Registered User
    Name: Bob Cowdery
    Organization: Personal
    Project: Software Radio
    Join Date
    Jan 2009
    Posts
    16
    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.

    Code:
    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*)'

  4. #4
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    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.

  5. #5
    bobc is offline Registered User
    Name: Bob Cowdery
    Organization: Personal
    Project: Software Radio
    Join Date
    Jan 2009
    Posts
    16
    Of course it is. I was just blind and forgot about the auto-generated file. Sorry for the noise.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem compiling Ice 3.3b
    By scottie in forum Bug Reports
    Replies: 6
    Last Post: 04-16-2008, 07:01 AM
  2. problem in compiling icestormS with vc6
    By leya in forum Help Center
    Replies: 5
    Last Post: 03-15-2006, 02:19 AM
  3. Problem compiling Icicle
    By andreynech in forum Help Center
    Replies: 10
    Last Post: 05-05-2004, 09:24 AM
  4. Problem compiling ICE 1.2.0 on Mandrake 9.1
    By amrufon in forum Help Center
    Replies: 8
    Last Post: 11-07-2003, 02:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •