Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 mingw build fails, typo in engine/CMakeLists.txt #25

Closed
DeltaLima opened this issue Jan 17, 2024 · 1 comment
Closed

Win32 mingw build fails, typo in engine/CMakeLists.txt #25

DeltaLima opened this issue Jan 17, 2024 · 1 comment

Comments

@DeltaLima
Copy link

Describe the bug
When compiling the win32 dedicated server executable, the build fails with cannot find -lWs2_32

$ mkdir -p mingw-build
$ cd mingw-build
$ export CC="ccache i686-w64-mingw32-gcc"
$ export CXX="ccache i686-w64-mingw32-g++"
$ export CFLAGS="-static-libgcc -no-pthread"
$ export CXXFLAGS="-static-libgcc -static-libstdc++"
$ cmake -DXASH_DEDICATED=ON -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS="-m32" -DCMAKE_C_FLAGS="-m32" ../
$ make -j2 VERBOSE=1
.... output ...

/usr/bin/ccache  i686-w64-mingw32-gcc -m32 -O2 -g -DNDEBUG   -Wl,--whole-archive CMakeFiles/xash.dir/objects.a -Wl,--no-whole-archive  -o xash_dedicated.exe -Wl,--out-implib,libxash_dedicated.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/xash.dir/linklibs.rsp
/usr/bin/i686-w64-mingw32-ld: cannot find -lWs2_32
collect2: error: ld returned 1 exit status
make[2]: *** [engine/CMakeFiles/xash.dir/build.make:1182: engine/xash_dedicated.exe] Error 1
make[2]: Leaving directory '/home/la10cy/xash3d/mingw-build'
make[1]: *** [CMakeFiles/Makefile2:91: engine/CMakeFiles/xash.dir/all] Error 2
make[1]: Leaving directory '/home/la10cy/xash3d/mingw-build'
make: *** [Makefile:152: all] Error 2
[  1%] Linking C executable xash_dedicated.exe
/usr/bin/i686-w64-mingw32-ld: cannot find -lWs2_32
collect2: error: ld returned 1 exit status
make[2]: *** [engine/CMakeFiles/xash.dir/build.make:1182: engine/xash_dedicated.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:91: engine/CMakeFiles/xash.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

Please complete the following information:

  • OS and Arch: Debian 12 amd 64 / Debian 10 amd64
  • Engine version: latest master branch, commit 3589a50

solution
looks like Ws2_32 has to be lower case in engine/CMakeLists.txt:

diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt
index 7196ab7d..8bd6aafa 100644
--- a/engine/CMakeLists.txt
+++ b/engine/CMakeLists.txt
@@ -125,7 +125,7 @@ endif()
 if(WIN32 AND NOT XASH_64BIT)
        add_definitions( -DDBGHELP -DXASH_W32CON) # dbghelp crashhandler
        if(MINGW)
-               target_link_libraries(${XASH_ENGINE} -luser32 -lkernel32 -lgdi32 -lWs2_32 -ldbghelp -lpsapi)
+               target_link_libraries(${XASH_ENGINE} -luser32 -lkernel32 -lgdi32 -lws2_32 -ldbghelp -lpsapi)
        elseif(MSVC)
                target_link_libraries(${XASH_ENGINE} user32.lib kernel32.lib gdi32.lib Ws2_32.lib dbghelp.lib psapi.lib)
        endif()
@@ -134,7 +134,7 @@ else()
                add_definitions(-DUSE_SELECT)
        endif()
         if(MINGW)
-                target_link_libraries(${XASH_ENGINE} -luser32 -lkernel32 -lgdi32 -lWs2_32)
+                target_link_libraries(${XASH_ENGINE} -luser32 -lkernel32 -lgdi32 -lws2_32)
         elseif(MSVC)
                 target_link_libraries(${XASH_ENGINE} user32.lib kernel32.lib gdi32.lib Ws2_32.lib)
         endif()

I wrote a blogpost about this to document it for myself and others, in case you need some more information :) : https://deltalima.org/blog/index.php/2024/01/17/howto-xcompile-xash3d-ng-for-reactos-on-linux/

@Mr0maks
Copy link
Collaborator

Mr0maks commented Jan 17, 2024

I wrote a blogpost about this to document it for myself and others, in case you need some more information :) : https://deltalima.org/blog/index.php/2024/01/17/howto-xcompile-xash3d-ng-for-reactos-on-linux/

We don't supply mingw builds because of its practical useless for Windows platform.
CI BUILDS FOR WINDOWS MSVC: https://ci.appveyor.com/project/tyabus/xash3d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants