我想把别人做的lib库用COM封装起来,成为COM组件,但连接的时候碰到问题,请大家帮忙分析一下,感谢先!先上100分再说!问题描述如下:
-------------------Configuration: zhjlfusion - Win32 Debug--------------------
Compiling...
FusionObject.cpp
Linking...
FusionObject.obj : error LNK2001: unresolved external symbol "unsigned short __cdecl SUM_CONTROL(struct __MIDL___MIDL_itf_zhjlfusion_0000_0010 *,struct __MIDL___MIDL_itf_zhjlfusion_0000_0002 *,struct __MIDL___MIDL_itf_zhjlfusion_0000_0001 *,struct _
_MIDL___MIDL_itf_zhjlfusion_0000_0007 *,struct __MIDL___MIDL_itf_zhjlfusion_0000_0008 *,struct __MIDL___MIDL_itf_zhjlfusion_0000_0009 *,struct __MIDL___MIDL_itf_zhjlfusion_0000_0004 *,struct __MIDL___MIDL_itf_zhjlfusion_0000_0003 *,struct __MIDL___M
IDL_itf_zhjlfusion_0000_0006 *,struct __MIDL___MIDL_itf_zhjlfusion_0000_0005 *,struct __MIDL___MIDL_itf_zhjlfusion_0000_0013 *,unsigned char *,struct __MIDL___MIDL_itf_zhjlfusion_0000_0012 *)" (?SUM_CONTROL@@YAGPAU__MIDL___MIDL_itf_zhjlfusion_0000_0
010@@PAU__MIDL___MIDL_itf_zhjlfusion_0000_0002@@PAU__MIDL___MIDL_itf_zhjlfusion_0000_0001@@PAU__MIDL___MIDL_itf_zhjlfusion_0000_0007@@PAU__MIDL___MIDL_itf_zhjlfusion_0000_0008@@PAU__MIDL___MIDL_itf_zhjlfusion_0000_0009@@PAU__MIDL___MIDL_itf_zhjlfusi
on_0000_0004@@PAU__MIDL___MIDL_itf_zhjlfusion_0000_0003@@PAU__MIDL___MIDL_itf_zhjlfusion_0000_0006@@PAU__MIDL___MIDL_itf_zhjlfusion_0000_0005@@PAU__MIDL___MIDL_itf_zhjlfusion_0000_0013@@PAEPAU__MIDL___MIDL_itf_zhjlfusion_0000_0012@@@Z)
Debug/zhjlfusion.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.zhjlfusion.exe - 2 error(s), 0 warning(s)
//////////////////////
其中SUM_CONTROL就是要使用的lib库中的带接口接口函数。lib库的头文件中该函数申明如下:
extern unsigned short  SUM_CONTROL(SIGN_C_STRU    *psign_cgq_in ,
   MS_265_STRU    *pms_265_in   ,     SCOUT_265_STRU  *pscout_265_in,
   MUL_204_STRU   *pmul_204_in  ,     SCOUT_204_STRU  *pscout_204_in,
   SCOUT_552_STRU *pscout_552_in, 
   MS_207_STRU    *pms_207_in   ,     SCOUT_207_STRU  *pscout_207_in,
   MS_206_STRU    *pms_206_in   ,     SCOUT_206_STRU  *pscout_206_in,
   DH_STRU        *pdh_in       ,
   unsigned char  *TARGETNUM    ,
   MAIN_MESS_STRU *MAIN_MESSAGE
   );

解决方案 »

  1.   

    连接一个别人做好的lib库,我不知道这个库的实现过程,听说是在VC环境下做的lib库,该库的名字叫IF162.lib,其中主要的函数接口为
    extern unsigned short  SUM_CONTROL(SIGN_C_STRU    *psign_cgq_in ,
            MS_265_STRU    *pms_265_in   ,          SCOUT_265_STRU  *pscout_265_in,
            MUL_204_STRU   *pmul_204_in  ,          SCOUT_204_STRU  *pscout_204_in,
                     SCOUT_552_STRU *pscout_552_in, 
            MS_207_STRU    *pms_207_in   ,          SCOUT_207_STRU  *pscout_207_in,
            MS_206_STRU    *pms_206_in   ,          COUT_206_STRU  *pscout_206_in,
            DH_STRU        *pdh_in       ,
            unsigned char  *TARGETNUM    ,
            MAIN_MESS_STRU *MAIN_MESSAGE);   还有别的没带参数的接口函数。
       在连接的时候,其他不带参数的函数没有连接错误,就是上边的带参数的接口函数连接错误,想不通是什么原因造成的,请大家指点迷津!
      

  2.   

    Maybe, you have use the structure itf_zhjlfusion by yourself in your interface defining file!!
    Do you use the structure defined by yourself in .idl file?
    you can extern the structure in .idl file.
      

  3.   

    谢谢phiger先!!!  
        那些结构类型的数据接口在他们提供的lib库文件里定义了,我只使用它们,在idl文件里也使用,我只是简单的做了一个包含那些数据结构的头文件,并在idl文件里用#include包含该头文件。
        请phiger帮我继续分析!
      

  4.   

    You must add the structure define in your .idl file,becuse your interface has used the structure!!like that :import "oaidl.idl";
    import "ocidl.idl";[
    uuid(24AAC930-6E8B-49C4-9B0E-30AE1B0AF84E),
    version(1.0),
    helpstring("Test 1.0 Type Library")
    ]
    library TestLib
    {
    importlib("stdole32.tlb");
    importlib("stdole2.tlb");
    typedef struct
    {
              }TAGTEST;
    [
    object,
    uuid(592E411D-17AB-4930-904F-A253AD7F31E3),
    dual,
    helpstring("ITest Interface"),
    pointer_default(unique)
    ]
    interface ITest : IDispatch
    {
    [id(1), helpstring("method Test")] HRESULT Test([in] TAGTEST test);
    };
    [
    uuid(DA7321E2-4217-4EE2-9B4F-76CF88CC0827),
    helpstring("Test Class")
    ]
    coclass Test
    {
    [default] interface ITest;        
    };
      

  5.   

    谢谢phiger,结构类型我在一个头文件里定义了,并且用#include包含进来了,这样和你做的有区别吗?
        
       还是回到问题,我使用的lib库是别人做的,在非COM程序里基本上可以编译连接好,但就是在ATL里不行,我不知道为什么,有时候怀疑是不是lib库的问题?请大家再帮我分析以下!!!
      

  6.   

    only include the header,it is not added into type library, you must define it in type library in the .idl file, understand???