3

我正在 Microsoft Visual C++ 10 中编译我的程序,它使用 PDCurses 库。我已将它配置为链接到 pdcurses.lib,但是当我尝试运行应用程序时,系统抱怨它找不到“pdcurses.dll”。它不应该抱怨它。我曾经用 MinGW (GCC) 编译程序,当我尝试运行应用程序时它不会询问我任何 DLL。我该怎么做才能使 MSVC 静态链接 PDCurses?

4

2 回答 2

8

In MSVC .lib files can take two forms:

  1. a static library
  2. an import library

The former can be used to make your application aware of the exported entry points from a DLL, which will then be written to the import directory of your PE file (or into another similar location for delay-loaded imports).

The latter, however, will actually link the code it contains for every referenced function into your final binary. This is what you want, but you may have to build that static library yourself from the source code, if it is not provided by the release of the library that you want to link.

However, there is another possibility: you could simply be passing the wrong directory for the linker to find the .lib files. In this case you'd be linking against the import library instead of the static library. Make sure you check your build log for the paths used. This, however, only applies if the distribution of the library contains both types of libraries.

于 2012-05-12T00:31:49.757 回答
-4

The dll needs to be in the path.

于 2012-05-12T00:35:48.960 回答