tyabus / xash3d

Bugfixed & Improved Xash3D
https://dsc.gg/tyabus
GNU General Public License v3.0
36 stars 12 forks source link

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

Closed DeltaLima closed 7 months ago

DeltaLima commented 7 months ago

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:

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 commented 7 months ago

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