Closed dbermond closed 2 years ago
By following the Qt documentation, I created a minimal CMake based Qt library whose clients successfully links to the shared library under Windows also with CMake and MSVC 2019.
By implementing the changes here, it still does not work. I could not yet figure out what is causing the problem. It looks like that some export is missing.
Interesting. Could you to set WINDOWS_EXPORT_ALL_SYMBOLS in QHotkey's CMakeLists.txt
?
Setting the WINDOWS_EXPORT_ALL_SYMBOLS
property on QHotkey's CMakeLists.txt
does not work for me. At the same way, using the CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
variable does not work either. I have tried it before. I also think that this would not be the optimal way to solve this issue.
Anyway, I found what's causing this. I will send a pull request with the fix.
Anyway, I found what's causing this. I will send a pull request with the fix.
Okay, great, looking forward to it!
When building QHotkey as a shared library on Windows with CMake and MSVC 2019 (
-DBUILD_SHARED_LIBS=ON
), compiling a client application leads to the following error:First of all, QHotkeys's
CMakeLists.txt
needs a fix to correctly build the shared library on Windows under MSVC. It lacks theQHOTKEY_LIB
andQHOTKEY_LIB_BUILD
definitions (referenced here), and in this way it will not produce theqhotkey.lib
file, but only theqhotkey.dll
one. Without this, a client application will not even pass the CMake step, telling that the imported qhotkey target references the fileqhotkey.lib
, and that it was not found.So, we need to add something like
add_definitions(-DQHOTKEY_LIB=1 -DQHOTKEY_LIB_BUILD=1)
to QHotkeys'sCMakeLists.txt
in order to MSVC to correctly generate theqhotkey.lib
. I've not sent any pull request because it's not sufficient to fix the issue.After this, compiling a client application fails with the link error above. Like the simple application example from the README file.
On Windows, I'm using the classic CMake build steps like on the README, with
cmake <args>
,cmake --build
andcmake --install
. No fancy compiler flags.This is the CMakeLists.txt that I'm using for the client application:
Linking from a static library compiled with CMake and MSVC 2019 works fine.
Not a Windows guy here, and maybe I'm doing something wrong, but that's what I could gather about this.