2013-10-26 13 views
0

兩個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 

謝謝大家。

+0

是的,context是一個保留關鍵字。請參閱CORBA v3.3規範的第1部分(請參閱http://www.omg.org/spec/CORBA/3.3/)。 7.2.4節列出了所有保留的關鍵字。您可以使用前導下劃線作爲在IDL中使用關鍵字的標準方式。 –

+0

@JohnnyWillemsen,你有沒有在我的更新文章中看到過這個新問題?我花了半天的時間,但沒有成功,, –

回答

0

您必須將anytypecode作爲基礎項目添加到IDL文件中的其他項目中,而不僅僅是IDL文件本身。也只是使用命名而不是namingexe,你只需要使用命名服務存根,而不是完整的服務實現

+0

錯誤是一樣的(見我的更新mpc文件)。我的理解是anytypecode lib是在鏈接期間添加的。問題是生成的基本庫文件沒有任何運算符<<符號,儘管它在testbaseC.h中定義並在testbaseC.cpp文件中實現。我認爲這是在鏈接testhelloclient庫期間沒有找到符號的原因。但我不知道如何解決這個問題.. –

+0

您是否在更改MPC文件後重新生成了解決方案,並且是否進行了全面清理,以便生成所有內容。此外,服務器必須鏈接testbaseC.cpp。 –

+0

您的客戶需要鏈接所有* C.cpp文件,您的CORBA服務器需要鏈接所有* C.cpp和* S.cpp文件! –