2

我得到以下错误:

'undefined reference to `CosNaming::NamingContext::_narrow(CORBA::Object*)'

这里是注册服务器的函数:

void registerServer(CORBA::ORB_var obj){


CORBA::Object_var nsobj = obj->resolve_initial_references("NameService");
CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow (nsobj);

if (CORBA::is_nil (nc)) {
    cerr << "Fehler: Konnte Naming Service nicht erreichen!" << endl;
    exit (1);
}

// Naming Service fuer unser Konto einrichten
CosNaming::Name name; 
name.length (1);
name[0].id = CORBA::string_dup ("VMS");
name[0].kind = CORBA::string_dup ("");
name[1].id = CORBA::string_dup("VMS_Context");
name[1].kind = CORBA::string_dup("");



cout << "VMS wird an Naming Service gebunden ... " << flush;
try{
 CosNaming::NamingContext_var namingContext = nc->bind_new_context(name);
}
catch(CosNaming::NamingContext::AlreadyBound_catch &ex){
    //darf ignoriert werden
}
cout << "done." << endl;

}

这里主要的funcitoncall:

CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");

  CORBA::Object_var poaobj = orb->resolve_initial_references("RootPOA");

  PortableServer::POA_var poa = PortableServer::POA::_narrow( poaobj);
  PortableServer::POAManager_var mgr = poa->the_POAManager();

  //My Object

  VMSRepository_i* myVMSRepository = new VMSRepository_i (100, 10);

  PortableServer::ObjectId_var oid = poa->activate_object(myVMSRepository);

  CORBA::Object_var ref = poa->id_to_reference(oid.in());


   registerServer(orb);

故障是由以下原因引起的:

CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow (nsobj);
4

0 回答 0