stohrendorf / CroftEngine

An open-source Tomb Raider 1 engine remake
Other
285 stars 18 forks source link

CroftEngine fails to build on MinGW and CYGWIN #273

Closed carlo-bramini closed 2 years ago

carlo-bramini commented 2 years ago

Compiling CroftEngine on my PC generates this error when linking the final executable:

[100%] Linking CXX executable croftengine.exe
soglb/libsoglb.a(cimgwrapper.cpp.o):cimgwrapper.cp:(.text$_ZN2gl12checkGlErrorEPKc[_ZN2gl12checkGlErrorEPKc]+0x0): multiple definition of `gl::checkGlError(char const*)'; soglb/libsoglb.a(glassert.cpp.o):glassert.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status

This happens because the whole source code is compiled without NDEBUG defined, but cimgwrapper.cpp.o instead has it, which is defined here:

https://github.com/stohrendorf/CroftEngine/blob/4820dca140f2fb5dc869e9193380c705629cb9a3/src/soglb/CMakeLists.txt#L59

I have not tried MSVC, but it seems that GNU tools didn't like this code. Is there a particular reason because it has been made that? Thank you very much.

stohrendorf commented 2 years ago

Interestingly, this works fine on Linux. The reason for NDEBUG being defined for that file is that the wrapper heavily slowed down startup in debug versions and became a bottleneck.