次の障害が発生します:
'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);