Archived

This forum has been archived. Please start a new discussion on GitHub.

server program aborts at createObjectAdapterWithEndpoints

Hi all,

I'm new to Ice and I'm trying to build a simple server program. So I copied code from the manual to make one. But the program aborts at this line:
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("MessagerAdapter", "default -p 10000");

The complete code is posted below:
#include "Ice/Ice.h"
#include "MessagerI.h"
#include <stdio.h>

using namespace std;
using namespace SHC;

int main(int argc, char* argv[])
{
    int status = 0;
    cout << "Declare Communicator" << endl; 
    Ice::CommunicatorPtr ic;
    try {
	cout << "Initialize Communicator" << endl; 
	ic = Ice::initialize(argc, argv);
	cout << "Initialize Adapter" << endl; 
	Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("MessagerAdapter", "default -p 10000");
	cout << "Point to MessagerI" << endl; 
	Ice::ObjectPtr object = new MessagerI;
	cout << "Add Object to Adapter" << endl; 
        adapter->add(object, ic->stringToIdentity("Messager"));
	cout << "Activate Adapter" << endl; 
        adapter->activate();
	cout << "Wait for shutdown" << endl; 
        ic->waitForShutdown();
    } catch (const Ice::Exception & e) {
        cerr << e << endl;
        status = 1;
    } catch (const char * msg) {
        cerr << msg << endl;
        status = 1;
    }
    if (ic){
        try {
            ic->destroy();
        } catch (const Ice::Exception & e) {
            cerr << e << endl;
            status = 1;
        }
    }
    return status;
}

I'm using the MS compiler cl.exe in cmd to compile.

Comments

  • benoit
    benoit Rennes, France
    Hi,

    You're code looks fine.

    Are you linking with the right Ice libraries? If you build your program with the debug runtime you need to link with iced.lib not ice.lib. If this isn't the issue, can you run the program in the debugger and get the stack trace of the abort?

    You could also try to modify the Ice minimal demo and see if it works (the minimal demo is in the demo/Ice/minimal directory and it should have been installed in the Documents\ZeroC\Ice-3.5.0-demos directory in your home directory).

    Cheers,
    Benoit.
  • NVM Problem solved!

    I actually figured it out! It turns out that I just need to turn of the debug mode! Thanks for your time anyway!:D
  • Thanks a lot!

    Looks like you posted the solution right when I was posting the NVM! Many thanks again! XD