How do I get CMake to create a dll and its matching lib file?
Asked Answered
N

2

39

I'm using CMake to create a shared library via Visual Studio 2010. The solution outputs a dll file, but not a matching lib file. How do I tell CMake to generate the lib file so I can link other projects to the dll?

Nematic answered 30/9, 2011 at 18:4 Comment(0)
I
44

First of all check that you have at least one exported symbol in your shared library. Visual Studio does not generate the .lib file if dll does not exports symbols.

Next, check your cmake files - probably you have set CMAKE_ARCHIVE_OUTPUT_DIRECTORY variable or ARCHIVE_OUTPUT_DIRECTORY property of the shared library target. If these variable/property is set then Visual Studio will output .lib files into the different directory specified by that variable/property. (There also can be configuration-specific versions like ARCHIVE_OUTPUT_DIRECTORY_Release.)

Infold answered 30/9, 2011 at 20:23 Comment(1)
I wasn't exporting any functions. Thanks!Nematic
W
4

add this command to your CMakeLists.txt set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

Weslee answered 25/3, 2023 at 6:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.