DLL隐式链接

时间:2014-04-05 14:18:45

标签: c dll dllimport dllexport

我不能隐式地将DLL链接到C控制台应用程序。 我使用的是Visual Studio 2008。

我创建了空DLL项目“Library”,它只包含一个文件main.c:

__declspec(dllexport) int get_value()
{
    return 123;
}

我还用文件main.c创建了空控制台项目“CallingProgram”:

__declspec(dllimport) int get_value();

void main()
{
    int result = get_value();
}

我将“Library.lib”添加到“Linker \ Input \ Additional Dependencies”。

我仍然有这个错误:

error LNK2019: unresolved external symbol __imp__get_value referenced in function _main

我使用LoadLibrary / GetProcAddress测试了创建的DLL - 它工作正常。

我使用DumpBin检查了Library.dll,它看起来也不错:

Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file library.dll

File Type: DLL

  Section contains the following exports for Library.dll

    00000000 characteristics
    5340072C time date stamp Sat Apr 05 17:37:48 2014
        0.00 version
           1 ordinal base
           1 number of functions
           1 number of names

    ordinal hint RVA      name

          1    0 00011109 get_value = @ILT+260(_get_value)

  Summary

        1000 .data
        1000 .idata
        2000 .rdata
        1000 .reloc
        1000 .rsrc
        4000 .text
       10000 .textbss

请帮助我理解缺少的东西!

0 个答案:

没有答案
相关问题