两个IDL文件生成的,testbase.idl库中无符号出口从CORBA IDL在VC
module Test{
enum JobType{
TYPE1,
TYPE2,
TYPE3
};
struct UserContext{
string name;
string ssoToken;
};
};
testhello.idl:
#include "testbase.idl"
module Test
{
interface Hello
{
void createJob(in UserContext type);
};
};
和Hello.mpc内容是:
project(testbaseIDL): taoidldefaults, anytypecode {
idlflags += -Wb,stub_export_macro=TEST_BASE_STUB_Export -Wb,stub_export_include=test_base_stub_export.h -Wb,skel_export_macro=TEST_BASE_SKEL_Export -Wb,skel_export_include=test_base_skel_export.h
IDL_Files {
testhello.idl
}
custom_only = 1
}
project(testhelloIDL): taoidldefaults, anytypecode {
idlflags += -Wb,stub_export_macro=TEST_HELLO_STUB_Export -Wb,stub_export_include=test_hello_stub_export.h -Wb,skel_export_macro=TEST_HELLO_SKEL_Export -Wb,skel_export_include=test_hello_skel_export.h
IDL_Files {
testhello.idl
}
custom_only = 1
}
project(test_base_server): naming, iortable, utils, avoids_corba_e_micro, anytypecode {
sharedname = test_base_server
after += *IDL
Source_Files {
testbaseS.cpp
}
Header_Files{
testbaseS.h
testbaseC.h
test_base_skel_export.h
}
dynamicflags += TEST_BASE_SKEL_BUILD_DLL TEST_BASE_STUB_BUILD_DLL
}
project(test_base_client): naming, iortable, utils,anytypecode {
sharedname = test_base_client
dynamicflags += TEST_BASE_STUB_BUILD_DLL
Source_Files {
testbaseC.cpp
}
Header_Files{
test_base_stub_export.h
testbaseC.h
}
}
project(testhelloserver): naming, iortable, utils, avoids_corba_e_micro,anytypecode {
sharedname = test_hello_server
dynamicflags += TEST_HELLO_SKEL_BUILD_DLL
libs += test_base_server test_hello_client test_base_client
Source_Files {
testhelloS.cpp
}
Header_Files{
testhelloS.h
testbaseS.h
test_hello_skel_export.h
}
}
project(testhelloclient): naming, iortable, utils,anytypecode {
sharedname = test_hello_client
dynamicflags += TEST_HELLO_STUB_BUILD_DLL
libs += test_base_client
Source_Files {
testhelloC.cpp
}
Header_Files{
testhelloC.h
testbaseC.h
test_hello_stub_export.h
}
}
我想做一些演示。 mpc将生成4个主要项目(testbaseClient,testbaseserver,testhelloServer和testhelloClient),每个项目将生成一个dll和库,并且它们全部用作每个IDL的骨架和存根。
在VS2008中,在构建testUDL,testbaseclient,testbaseServer之后,testbaseserver和testbaseclient的链接都会失败,因为链接找不到某些符号。该错误信息是:
1>testhelloC.obj : error LNK2019: unresolved external symbol "bool __cdecl operator::marshal(class TAO_OutputCDR &)" ([email protected][email protected]@[email protected]@[email protected]@@@[email protected]@[email protected]@@Z) 1>testhelloC.obj : error LNK2019: unresolved external symbol "void __cdecl operator::any_insert(class CORBA::Any *,struct Test::UserContext const &)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@@[email protected]@@@Z) 1>testhelloS.obj : error LNK2001: unresolved external symbol "void __cdecl operatortesthelloS.obj : error LNK2019: unresolved external symbol "bool __cdecl operator>>(class TAO_InputCDR &,struct Test::UserContext &)" ([email protected][email protected]@[email protected]@@@Z) referenced in function "public: virtual bool __thiscall TAO::In_Var_Size_SArgument_T::demarshal(class TAO_InputCDR &)" ([email protected][email protected]@[email protected]@[email protected]@@@[email protected]@[email protected]@@Z) 1>.\test_hello_serverd.dll : fatal error LNK1120: 3 unresolved externals
我理解错误:无法解析的外部符号只发生如果链接无法找到自己或依赖库的符号。因此,我加入 库+ = test_base_server test_base_client 两者testhelloclient和testhelloserver。重新生成所有项目后,结果是一样的。 “尚未解决的外部符号”仍然存在。
我怀疑这两个产生的基础库是错误的,我用命令: DUMPBIN/EXPORTS 导出所有符号和无报告解析的外部符号的存在。
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file test_base_clientd.dll File Type: DLL Section contains the following exports for test_base_clientd.dll 00000000 characteristics 526C30F9 time date stamp Sat Oct 26 18:15:37 2013 0.00 version 1 ordinal base 1 number of functions 1 number of names ordinal hint RVA name 1 0 00003130 [email protected]@@[email protected]@@Z = [email protected]@@[email protected]@@Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &)) Summary 1000 .data 2000 .idata 3000 .rdata 1000 .reloc 1000 .rsrc 9000 .text Microsoft (R) COFF/PE Dumper Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file test_base_serverd.dll File Type: DLL Section contains the following exports for test_base_serverd.dll 00000000 characteristics 526C2AEE time date stamp Sat Oct 26 17:49:50 2013 0.00 version 1 ordinal base 1 number of functions 1 number of names ordinal hint RVA name 1 0 00003130 [email protected]@@[email protected]@@Z = [email protected]@@[email protected]@@Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &)) Summary 1000 .data 2000 .idata 3000 .rdata 1000 .reloc 1000 .rsrc 9000 .text Microsoft (R) COFF/PE Dumper Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file test_base_serverd.lib File Type: LIBRARY Exports ordinal name [email protected]@@[email protected]@@Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &)) Summary E1 .debug$S 14 .idata$2 14 .idata$3 4 .idata$4 4 .idata$5 16 .idata$6 Microsoft (R) COFF/PE Dumper Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file test_base_clientd.lib File Type: LIBRARY Exports ordinal name [email protected]@@[email protected]@@Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &)) Summary E1 .debug$S 14 .idata$2 14 .idata$3 4 .idata$4 4 .idata$5 16 .idata$6
那我很困惑的是: 1)将连接需要使库项目中所有可用的符号。我过去在unix上的经验是,只有在制作可执行文件时才需要所有符号。
2)如何在这里解决这个问题?我应该为testIDL项目添加一些参数吗?
[更新]:
添加了所有* C.cpp为testhelloclient和所有* C.cpp和* S.cpp将使编制工作。
然而,这是不是如我所料。我想将每个IDL编译成两个库:一个用于存根,另一个用于框架。那么在将来,我只需要为其他项目提供带有相应头文件的存根/骨架。当.lib/.dll和头文件可用时,骨架/子应用程序不需要编译由IDL生成的任何cpp文件。
目前,没有一种上面生成* .lib文件包含来自* C.cpp或* S.cpp(该DUMPBIN结果作为交以前,只有1功能相似)符号。而其他应用程序仍会报告未解析的符号,因为.lib不包含任何导出符号。
我看MSDN:http://msdn.microsoft.com/en-us/library/ms235636%28v=vs.90%29.aspx今天下午。对于DLL的出口标志,函数声明为:
static __declspec(dllexport) double Add(double a, double b);
但IDL生成的C头文件似乎没有遵循这一方式..
VC在Linux中与GCC有很大不同。是否有一些解决方案?我不可能为IDL生成的头文件中的每个函数添加_declsepc?这个问题简化为:无符号的是出口在VC从IDL生成的库(我改名为标题更多的澄清)
[详细更新] 我回去tao_idl命令,现在看来,这是造成通过如下选项:-Wb,skeleton_export_include =“headerfile.h”export_macro ..
似乎所有这些文件和宏都生成....是否有更好的gernated .mpc文件,并且这些headerfile.h和宏?
[UPDATE] 它现在可以使用更新后的mpc文件(请参阅上文)。导出文件由位于$ ACE_ROOT/bin目录中的generate_export_file.pl生成。命令是这样的:
generate_export_file.pl TEST_HELLO_STUB > test_hello_stub_export.h
谢谢大家。
是的,context是一个保留关键字。请参阅CORBA v3.3规范的第1部分(请参阅http://www.omg.org/spec/CORBA/3.3/)。 7.2.4节列出了所有保留的关键字。您可以使用前导下划线作为在IDL中使用关键字的标准方式。 –
@JohnnyWillemsen,你有没有在我的更新文章中看到过这个新问题?我花了半天的时间,但没有成功,, –