[CMake] Link against exe on Windows fails - .a file not found

Michael Ho CraftedCart at outlook.com
Sun May 13 07:41:07 EDT 2018


Hey there.

I'm trying to make a plugin system for my application, and thus each plugin will need to link with my main application. This is fine on Linux and macOS, as I can just set the ENABLE_EXPORTS property of my executable target (set_target_properties(${PROJECT_NAME} PROPERTIES ENABLE_EXPORTS 1), and plugins will link just fine. On Windows however, clang++ yells at me that it can't find libws2editor.dll.a.

clang++.exe: error: no such file or directory: 'ws2editor/libws2editor.dll.a'

Upon looking over the CMake docs, it says "For DLL platforms an import library will be created for the exported symbols and then used for linking." - This import library file (presumably the .dll.a) never seems to be created though.


After a bit more digging around I came across <https://github.com/Kitware/CMake/blob/master/Tests/Plugin/CMakeLists.txt> https://github.com/Kitware/CMake/blob/master/Tests/Plugin/CMakeLists.txt - When I clone the CMake repo and try and compile that test myself, it also fails with the same error when using clang + ninja! When building with MSVC/msbuild however it compiles just fine (My project fails to configure when generating files for MSVC however, and ideally I'd like to use the same build config across Win/Mac/Linux).

So how can I get the CMake build on Windows to create this file, or otherwise link with an executable?
Thanks.

If you want the full CMake scripts, they're available on GitHub.
The main executable: <https://github.com/CraftedCart/smblevelworkshop2/blob/master/ws2editor/CMakeLists.txt> https://github.com/CraftedCart/smblevelworkshop2/blob/e85c2a0f6f9eb9a00f22b94aa79426b0874ca8e1/ws2editor/CMakeLists.txt
The plugin: https://github.com/CraftedCart/smblevelworkshop2/blob/e85c2a0f6f9eb9a00f22b94aa79426b0874ca8e1/ws2editorplugins/ws2editorexampleplugin/CMakeLists.txt


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180513/f7c2a687/attachment.html>


More information about the CMake mailing list