工程中的LINK异常
求教:工程中的LINK错误
建一个工程,在stdafx.h中定义了如下的变量:
extern EPIRPSystemImpl* g_EPIRPSystemImpl = 0
extern AlarmIRPSystemImpl* g_AlarmIRPSystemImpl = 0; ;
extern NotificationIRPSystemImpl* g_NotificationIRPSystemImpl = new 0;
extern BasicCmIRPSystemImpl* g_BasicCmIRPSystemImpl = 0;
当然EPIRPSystemImpl、AlarmIRPSystemImpl、NotificationIRPSystemImpl、BasicCmIRPSystemImpl这些类已经在其他.h中实现,并且已经包含
随后,在CDocument的派生类中声明这几个类成员
class CM31_SimulatorDoc : public CDocument
{
protected: // 仅从序列化创建
CM31_SimulatorDoc();
DECLARE_DYNCREATE(CM31_SimulatorDoc)
// 属性
public:
const char *str;
EPIRPSystemImpl* g_EPIRPSystemImpl;
AlarmIRPSystemImpl* g_AlarmIRPSystemImpl; ;
NotificationIRPSystemImpl* g_NotificationIRPSystemImpl;
BasicCmIRPSystemImpl* g_BasicCmIRPSystemImpl;
void export_object(
PortableServer::POA_ptr poa,
const PortableServer::ObjectId& oid,
const char* objref_file,
const char* type_id
);
DWORD WINAPI CrbThread(LPVOID lpP);
// 操作
public:
....
并且在对应的.cxx文件中实现这些函数export_object、CrbThread
void
CM31_SimulatorDoc::export_object(
PortableServer::POA_ptr poa,
const PortableServer::ObjectId& oid,
const char* objref_file,
const char* type_id
)
{
CORBA::Object_var ref = poa->create_reference_with_id(oid, type_id);
CORBA::String_var stringified_ref = global_orb->object_to_string(ref);
cout << "Writing stringified object reference to " << objref_file << endl;
IT_ofstream os(objref_file);
os << stringified_ref;
if (!os.good())
{
cerr << "Failed to write to " << objref_file << endl;
}
}
DWORD WINAPI CM31_SimulatorDoc::CrbThread(LPVOID lpP)
{
int argc = 0;
char* argv[4];
global_orb = CORBA::ORB_init(argc,argv);
CORBA::Object_var objPoa = global_orb->resolve_initial_references("RootPOA");
root_poa = PortableServer::POA::_narrow(objPoa.in());
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
/***************************************
* Create Persistent POA by tengwen *
***************************************/
CORBA::PolicyList policies(2);
policies.length(2);
policies[0] = root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
policies[1] = root_poa->create_id_assignment_policy(PortableServer::USER_ID);
PortableServer::POA_var persistent_poa =root_poa->create_POA("persistent",poa_manager,policies);
g_EPIRPSystemImpl = new EPIRPSystemImpl();
g_AlarmIRPSystemImpl = new AlarmIRPSystemImpl();
g_NotificationIRPSystemImpl = new NotificationIRPSystemImpl();
g_BasicCmIRPSystemImpl = new BasicCmIRPSystemImpl();
//log_string = "Create all IRP Implement Successfully...";
//OutputDebugString("hello kitty");
/********************************************************************************************
* Create and activate EPIRPSystemImpl、NotificationIRPSystemImpl、AlarmIRPSystemImpl *
* and BasicCmIRPSystemImpl object and the save EPIRPSystemImpl IOR to ftp server folder *
********************************************************************************************/
PortableServer::ObjectId_var inherit_oid = root_poa->activate_object(g_EPIRPSystemImpl);
建一个工程,在stdafx.h中定义了如下的变量:
extern EPIRPSystemImpl* g_EPIRPSystemImpl = 0
extern AlarmIRPSystemImpl* g_AlarmIRPSystemImpl = 0; ;
extern NotificationIRPSystemImpl* g_NotificationIRPSystemImpl = new 0;
extern BasicCmIRPSystemImpl* g_BasicCmIRPSystemImpl = 0;
当然EPIRPSystemImpl、AlarmIRPSystemImpl、NotificationIRPSystemImpl、BasicCmIRPSystemImpl这些类已经在其他.h中实现,并且已经包含
随后,在CDocument的派生类中声明这几个类成员
class CM31_SimulatorDoc : public CDocument
{
protected: // 仅从序列化创建
CM31_SimulatorDoc();
DECLARE_DYNCREATE(CM31_SimulatorDoc)
// 属性
public:
const char *str;
EPIRPSystemImpl* g_EPIRPSystemImpl;
AlarmIRPSystemImpl* g_AlarmIRPSystemImpl; ;
NotificationIRPSystemImpl* g_NotificationIRPSystemImpl;
BasicCmIRPSystemImpl* g_BasicCmIRPSystemImpl;
void export_object(
PortableServer::POA_ptr poa,
const PortableServer::ObjectId& oid,
const char* objref_file,
const char* type_id
);
DWORD WINAPI CrbThread(LPVOID lpP);
// 操作
public:
....
并且在对应的.cxx文件中实现这些函数export_object、CrbThread
void
CM31_SimulatorDoc::export_object(
PortableServer::POA_ptr poa,
const PortableServer::ObjectId& oid,
const char* objref_file,
const char* type_id
)
{
CORBA::Object_var ref = poa->create_reference_with_id(oid, type_id);
CORBA::String_var stringified_ref = global_orb->object_to_string(ref);
cout << "Writing stringified object reference to " << objref_file << endl;
IT_ofstream os(objref_file);
os << stringified_ref;
if (!os.good())
{
cerr << "Failed to write to " << objref_file << endl;
}
}
DWORD WINAPI CM31_SimulatorDoc::CrbThread(LPVOID lpP)
{
int argc = 0;
char* argv[4];
global_orb = CORBA::ORB_init(argc,argv);
CORBA::Object_var objPoa = global_orb->resolve_initial_references("RootPOA");
root_poa = PortableServer::POA::_narrow(objPoa.in());
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
/***************************************
* Create Persistent POA by tengwen *
***************************************/
CORBA::PolicyList policies(2);
policies.length(2);
policies[0] = root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
policies[1] = root_poa->create_id_assignment_policy(PortableServer::USER_ID);
PortableServer::POA_var persistent_poa =root_poa->create_POA("persistent",poa_manager,policies);
g_EPIRPSystemImpl = new EPIRPSystemImpl();
g_AlarmIRPSystemImpl = new AlarmIRPSystemImpl();
g_NotificationIRPSystemImpl = new NotificationIRPSystemImpl();
g_BasicCmIRPSystemImpl = new BasicCmIRPSystemImpl();
//log_string = "Create all IRP Implement Successfully...";
//OutputDebugString("hello kitty");
/********************************************************************************************
* Create and activate EPIRPSystemImpl、NotificationIRPSystemImpl、AlarmIRPSystemImpl *
* and BasicCmIRPSystemImpl object and the save EPIRPSystemImpl IOR to ftp server folder *
********************************************************************************************/
PortableServer::ObjectId_var inherit_oid = root_poa->activate_object(g_EPIRPSystemImpl);