[cmake-developers] Shared library under Windows and CMake: DLL not found before installation
Brad King
brad.king at kitware.com
Wed Feb 6 14:11:44 EST 2019
On 2/6/19 1:46 PM, Joachim Wuttke wrote:
> What is the minimally invasive adjustment
> to make the above build steps work under Windows?
Windows has no RPATH to help executables locate their shared
libraries. The simplest solution is to put the .exe and .dll
files in the same directory (which can be different from the .lib
import libraries corresponding to the .dll files).
Add code like this at the top of your project:
```
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
```
This will make all executables go to that one directory, which
may require some other adaptation in your code for other platforms
too. However, once done this will also put .dll files on Windows
in that directory.
-Brad
More information about the cmake-developers
mailing list