dhewm / dhewm3

dhewm 3 main repository
https://dhewm3.org/
GNU General Public License v3.0
1.81k stars 351 forks source link

neo/CMakekeLists.txt updates for compilation fixes in macOS #223

Closed Klezstyle closed 5 years ago

Klezstyle commented 5 years ago

Current GIT does not compile in macOS. I am proposing a few changes to CMakeLists.txt after the details

Details:

cmake creates macOS (x86_64) makefiles OK, but compilation fails because platform.h cannot find C++ included header files "cstddef" and "typeinfo". It´s interesting that it can include correctly the rest of ".h" headers.

The failure itself:

warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]

In file included from /Juegos/dhewm3/neo/idlib/bv/Bounds.cpp:29: /Juegos/dhewm3/neo/sys/platform.h:185:10: fatal error: 'cstddef' file not found

include \<cstddef>

    ^~~~~~~~~

1 warning and 1 error generated. make[2]: *** [CMakeFiles/idlib.dir/idlib/bv/Bounds.cpp.o] Error 1

These two include files work perfectly in my environment. Maybe Doom3 source code is being compiled as plain C instead of C++. I tested this with this little example:

"test.cpp"

include

include

include

include

include

include

include

include \<cstddef>

include \<typeinfo>

include

include

int main() { printf("Test include oK!"); return 0; }

g++ -O2 -Wall -Wextra test.cpp -o test.bin ./test.bin Test include oK!

but if the filename is changed to "test.c" and compiled as plain C: gcc -O2 -Wall -Wextra test.c -o test.bin test.c:10:10: fatal error: 'cstddef' file not found

This is the same behaviour as the compilation error being shown. And i think demonstrates that my environment is not broken.

My not 100% sure suggestion:

Update neo/CMakeLists.txt with the following changes (line numbers): 157 ++ add_compile_options(-stdlib=libc++) 202 (change to) add_compile_options(-arch x86_64 -mmacosx-version-min=10.9) 203 (change to) set(ldflags "${ldflags} -arch x86_64 -mmacosx-version-min=10.9")

That change means that 64 bit builds for mac will require at last macOS v10.9 "Mavericks" instead of 10.6 "Snow Leopard"

With these changes the source code can be fully compiled and the game can be launched. I can go in menu and hear the music. Unfortunately if i go to a new game the app crashes. I´m not sure if the crash is related to this "patch". Any advice is welcome.

Run log when entering new game just when the load bar reaches 100%: [https://pastebin.com/s3TYzpkL]

Crash-Backtrace: [https://pastebin.com/PKrWnxD7]

tip: Assertion failed: (rotation.GetOrigin() == start), function Motion, file /Juegos/dhewm3/neo/game/physics/Clip.cpp, line 1205.

Meanwhile i will try to experiment with different -std implementations, to see if this is the nail.

At last now the code compiles :)

Klezstyle commented 5 years ago

Now testing only with the SDK version without adding the -stdlib parameter mentioned in the previous post.

Modified these two neo/CMakeLists.txt lines to use version 10.14 macOS "Mojave":

[200] add_compile_options(-arch x86_64 -mmacosx-version-min=10.14) [201] set(ldflags "${ldflags} -arch x86_64 -mmacosx-version-min=10.14")

Now compiles OK but the crash is the same when i start a new game. Just after the loading progress bar reaches 100%

(...)
----- idSoundCache::EndLevelLoad -----
17443k referenced
  939k purged
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for constraint 'lwrist'
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for constraint 'lloarm'
WARNING: idAFTree::Factor: couldn't invert 5x5 matrix for constraint 'lankle'
WARNING: idAFTree::Factor: couldn't invert 5x5 matrix for constraint 'lloleg'
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for body waist
WARNING: idAFTree::Factor: couldn't invert 5x5 matrix for constraint 'lankle'
WARNING: idAFTree::Factor: couldn't invert 5x5 matrix for constraint 'lloleg'
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for body waist
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for constraint 'neck'
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for body chest
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for constraint 'chest'
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for body waist
WARNING: idAFTree::Factor: couldn't invert 5x5 matrix for constraint 'lankle'
WARNING: idAFTree::Factor: couldn't invert 5x5 matrix for constraint 'lloleg'
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for body waist
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for constraint 'neck'
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for body chest
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for constraint 'chest'
WARNING: idAFTree::Factor: couldn't invert 4x4 matrix for body waist
Assertion failed: (rotation.GetOrigin() == start), function Motion, file /Juegos/dhewm3/neo/game/physics/Clip.cpp, line 1205.
Looks like dhewm3 1.5.1pre crashed with signal SIGABRT (6) - sorry!

Backtrace:
  0   dhewm3                              0x000000010999a9f0 _ZL18signalhandlerCrashi + 112
  1   libsystem_platform.dylib            0x00007fff5bad5b3d _sigtramp + 29
  2   ???                                 0x00000000ffc00000 0x0 + 4290772992
  3   libsystem_c.dylib                   0x00007fff5b9931c9 abort + 127
  4   libsystem_c.dylib                   0x00007fff5b95b868 basename_r + 0
  5   base.dylib                          0x000000011501b955 _ZN6idClip6MotionER7trace_sRK6idVec3S4_RK10idRotationPK11idClipModelRK6idMat3iPK8idEntity + 3301
  6   base.dylib                          0x0000000115041dc8 _ZN12idPhysics_AF18CheckForCollisionsEf + 792
  7   base.dylib                          0x00000001150444e7 _ZN12idPhysics_AF8EvaluateEii + 1927
  8   base.dylib                          0x0000000114edb52f _ZN8idEntity10RunPhysicsEv + 303
  9   base.dylib                          0x0000000114ec17ce _ZN18idAFEntity_Generic5ThinkEv + 14
  10  base.dylib                          0x000000  24  CoreFoundation                      0x00007fff2e67c56d _CFXNotificationPost + 742
  25  Foundation                          0x00007fff30a04a7b -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
  26  AppKit                              0x00007fff2bc0164a -[NSApplication _postDidFinishNotification] + 313
  27  AppKit                              0x00007fff2bc00f6e -[NSApplication _sendFinishLaunchingNotification] + 209
  28  AppKit                              0x00007fff2bbfe8c8 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 552
  29  AppKit                              0x00007fff2bbfe517 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 690
  30  Foundation                          0x00007fff30a4f144 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 287
  31  Foundation                          0x00007fff30a4efc0 _NSAppleEventManagerGenericHandler + 102
  32  AE                                  0x00007fff2f934b93 _Z20aeDispatchAppleEventPK6AEDescPS_jPh + 1855
  33  AE                                  0x00007fff2f9343fd _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 41
  34  AE                                  0x00007fff2f9342d5 aeProcessAppleEvent + 439
  35  HIToolbox                           0x00007fff2d94910e AEProcessAppleEvent + 55
  36  AppKit                              0x00007fff2bbfa644 _DPSNextEvent + 1734
  37  AppKit                              0x00007fff2bbf9102 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
  38  AppKit                              0x00007fff2bbf3165 -[NSApplication run] + 699
  39  dhewm3                              0x000000010999d857 main + 1639
  40  libdyld.dylib                       0x00007fff5b8eaed9 start + 1

Abort trap: 6
Klezstyle commented 5 years ago

Not all maps crash, i managed to start the game with this map: ./dhewm3 +map game/caverns1

however most of the others end with a similar crash.

The graphics look incorrect with a "red filter" macos caverns1

Klezstyle commented 5 years ago

BIG BREAKTHROUGH!

I compiled SDL2 from todays GIT source and all the bugs and crashes are gone! I played the first entire level, no graphical bugs and mouse works too.

So, using official libsdl2 v2.0.9 gave me lots of problems, as detailed in the previous posts. But with current SDL2 GIT as 15-jan-2019 the game becomes fully playable without glitches.

using -arch x86_64 -mmacosx-version-min= from 10.6 to 10.8 do not compile because it can´t include C++ headers. Project compiles OK from 10.9 onwards.

Created pull request https://github.com/dhewm/dhewm3/pull/224 proposing the upgrade to minimum SDK version to 10.9 "Mavericks".

DanielGibson commented 5 years ago

I know that there are big problems with macOS Mojave, XCode 10 and OpenGL - Apple must have really fucked up things badly there. AFAIK SDL added lots of workarounds for those problems at some point after the 2.0.9 release, which might explain why latest SDL code works better

Also: Great work, thanks! :)

Klezstyle commented 5 years ago

That´s the problem changing APIS, references, etc every two years with each "new" macOS version.

Because of this, i expected problems trying to compile this project from macOS v10.14 that will look for an v10.6 SDK (Snow Leopard from 2009) and when there were 8 new mac os versions... I can imagine the hell must be suffering Ryan Gordon of libSDL trying to keep compatibility with all those different macOS versions.

Anyway the changes of pull will be harmless and nobody left behind, because most of 64 bit mac computers can use osx v10.9 and do not have any reason to use older versions.

This bug can be closed when the pull is merged. Thank you Daniel.