vkoskiv / c-ray

c-ray is a small, simple path tracer written in C
MIT License
797 stars 44 forks source link

Failed to build on MSYS2 MINGW64 #113

Open ghost opened 1 year ago

ghost commented 1 year ago
FAILED: CMakeFiles/c-ray.dir/src/c-ray.c.obj
C:\msys64\mingw64\bin\cc.exe -DCRAY_SDL_ENABLED -IC:/msys64/home/Administrator/c-ray/src -IC:/msys64/home/Administrator/c-ray/tests -IC:/msys64/mingw64/include/SDL2 -Wall -Wextra -Wno-missing-field-initializers -std=gnu99 -D_GNU_SOURCE -O2 -ftree-vectorize -g -flto=auto -fno-fat-lto-objects -MD -MT CMakeFiles/c-ray.dir/src/c-ray.c.obj -MF CMakeFiles\c-ray.dir\src\c-ray.c.obj.d -o CMakeFiles/c-ray.dir/src/c-ray.c.obj -c C:/msys64/home/Administrator/c-ray/src/c-ray.c
In file included from C:/msys64/home/Administrator/c-ray/src/c-ray.c:30:
C:/msys64/home/Administrator/c-ray/src/utils/protocol/server.h:12:10: fatal error: arpa/inet.h: No such file or directory
   12 | #include <arpa/inet.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
vkoskiv commented 1 year ago

Hey, thanks for reporting. Currently, the network protocol is not supported on Windows, as it assumes a Berkeley sockets style API. I'm guarding the network code with a simple #ifndef WINDOWS. Reworking these guards is needed to get it building on MINGW environments. I don't have a MINGW environment available, but the included instructions in the README on how to build natively on Windows should still work.

ghost commented 1 year ago

Hey, thanks for reporting. Currently, the network protocol is not supported on Windows, as it assumes a Berkeley sockets style API. I'm guarding the network code with a simple #ifndef WINDOWS. Reworking these guards is needed to get it building on MINGW environments. I don't have a MINGW environment available, but the included instructions in the README on how to build natively on Windows should still work.

Shouldn't it be #ifndef _WIN32? Your usage of #ifndef WINDOWS is wrong. This is the reason why <arpa/inet.h> is still included.

ghost commented 1 year ago

Oh I see, -DWINDOWS is added by you on your CMakeLists.txt. @vkoskiv What about replacing #ifndef WINDOWS in code with #ifndef _WIN32 so you will not need to define -DWINDOWS on CMakeLists.txt? Btw, please have a look at your CMakeLists.txt and add support for MinGW compiler. You could use if (MinGW) to check for MinGW on CMake. Currently you only check for MSVC so -DWINDOWS is not defined when building with MSYS2.

vkoskiv commented 1 year ago

Btw, please have a look at your CMakeLists.txt and add support for MinGW compiler.

I personally don't have a need for MinGW support, nor a test environment to implement that support, but I'd be happy to merge in those changes if someone else works on it.