<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<div class="postcell post-layout--right">Hey there.<br>
</div>
<div class="postcell post-layout--right"><br>
</div>
<div class="postcell post-layout--right">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 (<code><span style="background-color: rgb(204, 204, 204);">set_target_properties(${PROJECT_NAME} PROPERTIES ENABLE_EXPORTS 1</span></code>), and plugins will link just fine. On Windows however,
<code>clang++</code> yells at me that it can't find <code>libws2editor.dll.a</code>.
<div class="post-text" itemprop="text">
<pre class="lang-cpp prettyprint prettyprinted" style=""><code><span class="pln" style="background-color: rgb(204, 204, 204);">clang</span><span class="pun" style="background-color: rgb(204, 204, 204);">++.</span><span class="pln" style="background-color: rgb(204, 204, 204);">exe</span><span class="pun" style="background-color: rgb(204, 204, 204);">:</span><span class="pln" style="background-color: rgb(204, 204, 204);"> error</span><span class="pun" style="background-color: rgb(204, 204, 204);">:</span><span class="pln" style="background-color: rgb(204, 204, 204);"> no such file or directory</span><span class="pun" style="background-color: rgb(204, 204, 204);">:</span><span class="pln" style="background-color: rgb(204, 204, 204);"> </span><span class="str" style="background-color: rgb(204, 204, 204);">'ws2editor/libws2editor.dll.a'</span></code></pre>
<p>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.</p>
<p><br>
</p>
</div>
</div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="comment-copy">After a bit more digging around I came across <a href="https://github.com/Kitware/CMake/blob/master/Tests/Plugin/CMakeLists.txt" rel="nofollow noreferrer">
</a><a href="https://github.com/Kitware/CMake/blob/master/Tests/Plugin/CMakeLists.txt" id="LPNoLP894152">https://github.com/Kitware/CMake/blob/master/Tests/Plugin/CMakeLists.txt</a> - 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).</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="comment-copy"><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="comment-copy">So how can I get the CMake build on Windows to create this file, or otherwise link with an executable?</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="comment-copy">Thanks.<br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="comment-copy"><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="comment-copy">If you want the full CMake scripts, they're available on GitHub.<br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="comment-copy">The main executable: <a href="https://github.com/CraftedCart/smblevelworkshop2/blob/master/ws2editor/CMakeLists.txt" id="LPlnk297925">
</a><a href="https://github.com/CraftedCart/smblevelworkshop2/blob/e85c2a0f6f9eb9a00f22b94aa79426b0874ca8e1/ws2editor/CMakeLists.txt" id="LPNoLP457585">https://github.com/CraftedCart/smblevelworkshop2/blob/e85c2a0f6f9eb9a00f22b94aa79426b0874ca8e1/ws2editor/CMakeLists.txt</a><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="comment-copy">The plugin: <a href="https://github.com/CraftedCart/smblevelworkshop2/blob/e85c2a0f6f9eb9a00f22b94aa79426b0874ca8e1/ws2editorplugins/ws2editorexampleplugin/CMakeLists.txt" id="LPNoLP891580">https://github.com/CraftedCart/smblevelworkshop2/blob/e85c2a0f6f9eb9a00f22b94aa79426b0874ca8e1/ws2editorplugins/ws2editorexampleplugin/CMakeLists.txt</a>
</span><br>
</div>
<br>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
</body>
</html>