Closed gaurav21r closed 6 months ago
This is what I use to build for Windows locally:
Z:
cd Z:\IdeaProjects\JNativeHook\src\external\libuiohook
cmake -B .\build ^
-G "Visual Studio 16 2019" -A x64 ^
-D CMAKE_INSTALL_PREFIX=.\dist\windows\x86_64 ^
-D CMAKE_VERBOSE_MAKEFILE=true ^
-D USE_EPOCH_TIME=OFF ^
-D BUILD_SHARED_LIBS=ON ^
-D BUILD_DEMO=ON
cmake --build .\build ^
--parallel 2 ^
--config RelWithDebInfo
cmake --install .\build --config RelWithDebInfo
You probably need to switch out -G mingw32-make
if you want to build with MinGW. See https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#manual:cmake-generators(7)
@kwhat Thank you for this, in the process of trying out dozens of combinations, I think I wrote this as well but probably missed out on the -A
switch. Also, irritatingly, installing Visual Studio doesn't update the PATH
by default. Maybe I am missing something there. I will try with MinGW and close this thread if successful. Just a few questions:
Do you think it would be good if we added this to README or maybe somewhere else in the docs? Apologies if this is already there.
I'm always a bit confused with the Architecture switch. Processors like i3, i5, i 7 are x64
right? AMD processors would also be x64
? What about building for Windows on ARM is that supported? If so, what would be the correct value for -A
then? I went through the link you gave and CMake also has a Win32
value for the -A
switch. What would be the target platform then?
Is there any difference in the functioning / performance of libuiohook
with compiling with Visual Studio vs compiling with MinGW?
Also, irritatingly, installing Visual Studio doesn't update the PATH by default.
Visual Studio uses its own shell. You need to compile from the shell launched by C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat
. You can find these tool shortcuts here: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC
. I am sure there is a reason for this like having multiple tool-chains installed at the same time. Windows is really just a pain in general, but not nearly as much of a pain as MacOS.
Processors like i3, i5, i 7 are x64 right?
Anything modern is going to be x64 (aka amd64, X86-64 or k8). Sometimes you want Win32 (aka x86 or i386) compatibility because Windows still ships a lot of 32-bit software for whatever reason. See Wow64.
What about building for Windows on ARM is that supported?
Yes, you can look at the build scripts that package artifacts for this repo here: https://github.com/kwhat/libuiohook/blob/1.2/.github/workflows/package.yml#L342 This builds everything currently supported except for BSD.
Is there any difference in the functioning / performance of libuiohook with compiling with Visual Studio vs compiling with MinGW?
Not really, a lot of work went into making sure it would compile with gcc/clang on Windows. This may not be the case moving forward, but for now its fine.
@kwhat Thank you very much for this wonderful Library. Its the only one that works without any edge conditions.
I am making a cross platform Macro Recorder and was able to use this library flawlessly for Mac. However I'm getting the following error while compiling for windows:
I have installed MIngW (for gcc), Cmake for Windows and also Visual Studio.
Please let me know what I am missing and apologies if this seems like a noob question, I am new to the C / C++ / CMake land!