Go Back   ZeroC Forums > Comments

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 06-22-2009
bobc 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
Reply With Quote
  #2 (permalink)  
Old 06-22-2009
dwayne's Avatar
dwayne 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: 363
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.
Reply With Quote
  #3 (permalink)  
Old 06-22-2009
bobc 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*)'
Reply With Quote
  #4 (permalink)  
Old 06-22-2009
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,402
Quote:
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.
Reply With Quote
  #5 (permalink)  
Old 06-22-2009
bobc 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.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem compiling Ice 3.3b scottie Bug Reports 6 04-16-2008 06:01 AM
problem in compiling icestormS with vc6 leya Help Center 5 03-15-2006 01:19 AM
Problem compiling Icicle andreynech Help Center 10 05-05-2004 08:24 AM
Problem compiling ICE 1.2.0 on Mandrake 9.1 amrufon Help Center 8 11-07-2003 01:45 AM


All times are GMT -4. The time now is 09:41 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2009 ZeroC, Inc.