I am compiling my program in Microsoft Visual C++ 10, and it uses the PDCurses library. I have configured it to link against pdcurses.lib but when I try to run the application the system complains that it can't find "pdcurses.dll". It's not supposed to complain about it. I used to compile programs with MinGW (GCC) and it doesn't ask me about any DLL when I try to run the application. What can I do so that MSVC statically links PDCurses?

- 62,044
- 9
- 127
- 211

- 1,203
- 3
- 17
- 23
-
8It sounds like this pdcurses.lib isn't really a standalone static library, it's an import library for the DLL. You need to make sure that you have a standalone static library that doesn't require the DLL. – James McNellis May 11 '12 at 22:26
2 Answers
In MSVC .lib
files can take two forms:
- a static library
- 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.

- 20,597
- 9
- 86
- 152
-
Well I have both pdcurses.lib and pdcurses.dll in the same directory. I have set the "additional libraries" path to that directory, so it's supposed to find the .lib. And in the "input" field I have added pdcurses.lib. I used to statically link pdcurses into other applications with GCC. It seems to me that the problem is with some MSVC configuration, but I can't find out what exactly it is. – Fernando Aires Castello May 12 '12 at 19:02
-
Just because you have a `lib.` doesn't say anything about what type of `.lib` it is. An easy empirical method to find out is whether the DLL is smaller or bigger than the `.lib`. If it is bigger, it is likely that the `.lib` is merely an import library. If it is smaller, the `.lib` is likely the static library you are looking for. Include the details from your build log into your question and we may be able to help further. GCC as comparison makes no sense here, because that uses either the archive (`.a`) or the `.so` directly. In MSVC the import library (`.lib`) is needed for dynamic linking. – 0xC0000022L May 12 '12 at 19:36
The dll needs to be in the path.

- 28,120
- 21
- 85
- 141
-
2
-
If you want to use PDCurses, you must put the dll in the path. after that you can link to the interface library and things work. – EvilTeach Nov 06 '12 at 00:38