简体   繁体   English

从VC中的Corba IDL生成的库中没有符号导出

[英]NO symbol export in library generated from Corba IDL in VC

Two IDL files, testbase.idl 两个IDL文件testbase.idl

module Test{
   enum JobType{
       TYPE1,
        TYPE2,
       TYPE3
   };

   struct UserContext{
       string name;
       string ssoToken;
   };
};

testhello.idl: testhello.idl:

#include "testbase.idl"
module Test 
{
   interface Hello
   {
    void createJob(in UserContext type);
   };
};

and Hello.mpc content is: 而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
      }
  }

I want to do some demo. 我想做一些演示。 The mpc would generate 4 main projects(testbaseClient, testbaseserver, testhelloServer and testhelloClient) and each projects would generate one dll and library and all of them are used as skeleton and stub for each IDL. 该mpc将生成4个主要项目(testbaseClient,testbaseserver,testhelloServer和testhelloClient),每个项目将生成一个dll和库,并且所有这些都用作每个IDL的框架和存根。

In VS2008, after building testUDL, testbaseclient, testbaseServer, the links for both testbaseserver and testbaseclient fail because link can not find some symbols. 在VS2008中,在构建testUDL,testbaseclient,testbaseServer之后,由于链接找不到某些符号,因此testbaseserver和testbaseclient的链接均失败。 The error messages are: 错误消息是:

1>testhelloC.obj : error LNK2019: unresolved external symbol "bool __cdecl operator::marshal(class TAO_OutputCDR &)" (?marshal@?$In_Var_Size_Argument_T@UUserContext@Test@@VAny_Insert_Policy_Stream@TAO@@@TAO@@UAE_NAAVTAO_OutputCDR@@@Z)
1>testhelloC.obj : error LNK2019: unresolved external symbol "void __cdecl operator::any_insert(class CORBA::Any *,struct Test::UserContext const &)" (?any_insert@?$Any_Insert_Policy_Stream@UUserContext@Test@@@TAO@@SAXPAVAny@CORBA@@ABUUserContext@Test@@@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 &)" (??5@YA_NAAVTAO_InputCDR@@AAUUserContext@Test@@@Z) referenced in function "public: virtual bool __thiscall TAO::In_Var_Size_SArgument_T::demarshal(class TAO_InputCDR &)" (?demarshal@?$In_Var_Size_SArgument_T@UUserContext@Test@@VAny_Insert_Policy_Stream@TAO@@@TAO@@UAE_NAAVTAO_InputCDR@@@Z)
1>.\test_hello_serverd.dll : fatal error LNK1120: 3 unresolved externals

I understand the error: unresolved external symbol happens only if link could not find those symbol from itself or dependent libraries. 我理解错误:无法解析的外部符号仅在链接无法从自身或从属库中找到这些符号时发生。 Therefore, I added libs += test_base_server test_base_client for both testhelloclient and testhelloserver. 因此,我为testhelloclient和testhelloserver添加了libs + = test_base_server test_base_client。 After regenerating all project, the result is the same. 重新生成所有项目后,结果是相同的。 The "unresolved external symbol" still there. “未解决的外部符号”仍然存在。

I suspect the two generated base library are wrong and I use command: dumpbin /EXPORTS to export all symbol and none reported unresolved external symbol are there. 我怀疑生成的两个基本库是错误的,我使用命令: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 ??4_Init_locks@std@@QAEAAV01@ABV01@@Z = ??4_Init_locks@std@@QAEAAV01@ABV01@@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 ??4_Init_locks@std@@QAEAAV01@ABV01@@Z = ??4_Init_locks@std@@QAEAAV01@ABV01@@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

                  ??4_Init_locks@std@@QAEAAV01@ABV01@@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

                  ??4_Init_locks@std@@QAEAAV01@ABV01@@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

Then what I am confused is that: 1) Would link requires all symbol available during making library project. 那么我感到困惑的是:1)链接需要在制作库项目期间所有可用的符号。 What my past experience in unix is that all symbol is required only if it is on making executable file. 我过去在UNIX中的经验是,只有在制作可执行文件时才需要使用所有符号。

2) How to resolve this issue here? 2)如何在此解决此问题? Should I add some arguments for testIDL projects? 我应该为testIDL项目添加一些参数吗?

[UPdate]: [更新]:

Added all *C.cpp for testhelloclient and all *C.cpp and *S.cpp would make compilation work. 为testhelloclient添加了所有* C.cpp,所有* C.cpp和* S.cpp将使编译工作。

However, this is not as I expected. 但是,这与我预期的不同。 I want to compile each IDL into two libraries: one is for stub and another is for skeleton. 我想将每个IDL编译成两个库:一个用于存根,另一个用于骨架。 Then in the future, I only need to deliver stub/skeleton with corresponding header files for other projects. 然后在将来,我只需要为其他项目提供带有相应头文件的存根/骨架。 It is unnecessary for skeleton/sub application to compile any of cpp files generated by IDL when .lib/.dll and header file is available. 当.lib / .dll和头文件可用时,骨架/子应用程序不必编译IDL生成的任何cpp文件。

Currently, none of *.lib files generated above contain symbol from *C.cpp or *S.cpp(the dumpbin result is similar as post previous, only 1 function). 当前,上面生成的* .lib文件都没有包含* C.cpp或* S.cpp中的符号(dumpbin结果与先前发布的结果类似,只有1个函数)。 And other application would still report unresolve symbols because .lib does not contain any export symbols. 其他应用程序仍将报告未解析符号,因为.lib不包含任何导出符号。

I read MSDN: http://msdn.microsoft.com/en-us/library/ms235636%28v=vs.90%29.aspx this afternoon. 我今天下午阅读了MSDN: http : //msdn.microsoft.com/en-us/library/ms235636%28v=vs.90%29.aspx For export symbol of dll, the function is declared as: 对于dll的导出符号,该函数声明为:

static __declspec(dllexport) double Add(double a, double b);

but idl generated c header files seems not follow this way.. 但是idl生成的c头文件似乎不遵循这种方式。

VC seems much different with GCC in Linux. VC与Linux中的GCC似乎有很大不同。 Is there some solution?It is impossible for I to add _declsepc for each functions in IDL generated header files? 有什么解决方案吗?我不可能在IDL生成的头文件中为每个函数添加_declsepc吗? The issue is simplified as: none of symbols is export in library generated from IDL in VC(I renamed title for more clarification) 问题简化为:在VC中从IDL生成的库中没有导出任何符号(为了更清楚起见,我重命名了标题)

[More update] I go back to the tao_idl command, it seems it is caused by options like: -Wb,skeleton_export_include="headerfile.h" export_macro.. [更多更新]我回到tao_idl命令,看来它是由诸如-Wb,skeleton_export_include =“ headerfile.h” export_macro之类的选项引起的。

It seems all these files and macros are generated....Is there any better to gernated .mpc file and are these headerfile.h and macros? 似乎所有这些文件和宏都已生成。...有没有更好的通用.mpc文件,并且这些headerfile.h和宏是?

[UPDATE] It now works with updated mpc file(see above). [更新]现在可用于更新的mpc文件(请参见上文)。 The export files are generated by generate_export_file.pl which is in $ACE_ROOT/bin directory. 导出文件由$ ACE_ROOT / bin目录中的generate_export_file.pl生成。 The command is like: 该命令类似于:

generate_export_file.pl TEST_HELLO_STUB > test_hello_stub_export.h

Thanks all. 谢谢大家

You have to add anytypecode also as base project in the other projects in the IDL file, not only with the IDL file itself. 您还必须在IDL文件的其他项目中添加anytypecode作为基础项目,而不仅仅是IDL文件本身。 Also just use naming instead of namingexe, you only need to use the naming service stubs, not the full service implementation 同样只使用命名而不是namingexe,您只需要使用命名服务存根,而不是完整的服务实现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM