这是因为没有DEF文件。这样的DLL若用BC++调用可能会有问题。

解决方案 »

  1.   

    Name DecorationNormally this refers to C++ naming conventions, but it applies to a number of non-C++ cases as well. C++ by default will use the name of a function, its parameters and its return type when calculating a name for a function. The linker function name for void CALLTYPE test(void)might come to anything in the table below depending on what CALLTYPE is and what language you are using. CALLTYPEs such as __cdecl, __fastcall, and __stdcall can change the naming conventions for a function/variable. 
    Calling convention         |  extern “C” or .C file  |  .CPP , .CXX or /TP 
    -----------------------------------------------------------------------------
    C naming convention        |        _test              |   ?test@@ZAXXZ  
    (__cdecl)                  |                           |
    -----------------------------------------------------------------------------
    Fastcall naming convention |       @test@0             |   ?test@@YIXXZ 
    (__fastcall)               |                           |
    -----------------------------------------------------------------------------
    Standard Call naming       |       _test@0             |   ?test@@YGXXZ 
    convention (__stdcall)     |                           |Use extern “C” when calling a C function from a C++ program. Extern “C” forces use of the C naming convention for non-class C++ functions. Be aware of compiler switches like /TP or /Tc that force a file to be compiled as a C (/Tc) or C++ (/TP) file no matter what the filename extension, or you may get different function names than you expect.Having function prototypes that have mismatched parameters can also cause this error. Name decoration incorporates the parameters of a function into the final decorated function name. Calling a function with the parameter types that do not match those in the function declaration may also cause LNK2001. There is currently no standard for C++ naming between compiler vendors or even between different versions of a compiler. Therefore linking object files compiled with other compilers may not produce the same naming scheme and thus causes unresolved externals.
      

  2.   

    在DEF文件中是没有加说明,但是MSDN上好象是说,如果用此关键字可以不要DEF文件的
      

  3.   

    你在setings中,加入你的*.lib文件试试,我遇到这个问题时好象是这样解决的。
    方法:你把*.lib文件,拷入你的工作目录下,或者,你把他拷入System32目录下OR
    project-->Setings-->Link-->Object/library moudles 中加入你做的动态库的*.lib文件。
      

  4.   

    你自己定义的函数用这样的方法
    #ifdef __cplusplus
    extern "C" {
    #endif
    int __declspec(dllimport) fn(int i);
    #ifdef __cplusplus
    }
    #endif
      

  5.   

    偶看过han012(阿毛)写的,你也可以耐心观看!
      

  6.   

    不用__declspec(dllimport) 来导出函数也可以,只要在DEF中加函数定义就可以.