enriquesomolinos / DreeRally

Death Rally engine reimplementation
http://www.dreerally.com
81 stars 12 forks source link

Portability #29

Open mmiszczyk opened 5 years ago

mmiszczyk commented 5 years ago

Is your feature request related to a problem? Please describe. According to the website, one of the stated goals of the project is the possibilty to port Death Rally to other platforms. However, current codebase is strongly coupled with Windows/Visual Studio/MSVC environment.

Describe the solution you'd like There are several issues which prevent us from being able to compile DreeRally for e.g. Linux. The most obvious one is Windows-specific C functions and headers. They should be identified and replaced with SDL equivalents (if graphics/windowing/GUI related) or with ISO C equivalents (if related to things like e.g. file access). If all else fails, we can use #ifdef macros.

Less obvious issues are non-standard language elements (e.g. I'm pretty sure that some of the #pragmas are MSVC specific and won't work with gcc or clang) and build process. I think that pragmas are mostly used to suppress warnings, which I think is something we could live without. As for build process, it seems simple enough - shouldn't be too hard to make an equivalent Makefile.

Describe alternatives you've considered Running in Wine, I guess? But I think source portability would be preferable.

Additional context N/A

neuromancer commented 5 years ago

Related with #17 . Also, I saw a branch with cmake support, was it deleted or merged @enriquesomolinos ?

enriquesomolinos commented 5 years ago

Yes, this is one of the main golas of the project. I try to create a stable window version in this months to start this task later.

neuromancer commented 4 years ago

@enriquesomolinos it seems you are trying to fix travis to build the portability branch. Do you need some help with that?

enriquesomolinos commented 4 years ago

yes, help will be appreciated. In my locla computer dreerally compiles fine, but in travis libraries are not well recognized

neuromancer commented 4 years ago

I'm taking a look to this issue again..

enriquesomolinos commented 4 years ago

Thanks for the contribution neuromancer, the code compiles fine 👍 . Now i need to solve some problems in order to have a functional executable under linux.

neuromancer commented 4 years ago

It fails to run here:

$ LD_LIBRARY_PATH=. gdb --quiet --args ./dreerally.exe 
Reading symbols from ./dreerally.exe...done.
(gdb) r
Starting program: /home/g/Games/DreeRally/dreerally.exe 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
free(): invalid next size (normal)

Program received signal SIGABRT, Aborted.
0xf7fd5059 in __kernel_vsyscall ()
(gdb) bt
#0  0xf7fd5059 in __kernel_vsyscall ()
#1  0xf7b53832 in raise () from /lib/i386-linux-gnu/libc.so.6
#2  0xf7b54cc1 in abort () from /lib/i386-linux-gnu/libc.so.6
#3  0xf7b95bd3 in ?? () from /lib/i386-linux-gnu/libc.so.6
#4  0xf7b9c7ed in ?? () from /lib/i386-linux-gnu/libc.so.6
#5  0xf7b9e15b in ?? () from /lib/i386-linux-gnu/libc.so.6
#6  0xf77d79f7 in _XFreeDisplayStructure () from /usr/lib/i386-linux-gnu/libX11.so.6
#7  0xf77c481c in XCloseDisplay () from /usr/lib/i386-linux-gnu/libX11.so.6
#8  0xf7ddad9c in ?? () from /usr/lib/i386-linux-gnu/libSDL-1.2.so.0
#9  0xf7dcd351 in SDL_VideoInit () from /usr/lib/i386-linux-gnu/libSDL-1.2.so.0
#10 0xf7da4268 in SDL_InitSubSystem () from /usr/lib/i386-linux-gnu/libSDL-1.2.so.0
#11 0x565bc213 in inicializeScreen (a1=3.75) at dr.c:34658
#12 0x565b9848 in sub_43ACE0 (a1=3.75, a2=1, a3=-11996, args=0x56b11910 "/home/g/Games/DreeRally/home\301\004") at dr.c:32972
#13 0x565bef9d in initSystem (fmodMinVersion=3.75, a1=1, a2=0xffffd124, args=0x56b11910 "/home/g/Games/DreeRally/home\301\004") at dr.c:35899
#14 0x565bf140 in main (argc=1, argv=0xffffd214) at dr.c:35968
neuromancer commented 4 years ago

@enriquesomolinos I tested the latest revision of the feature-portability branch (which is in a PR right now), and I'm getting this error:

$ LD_LIBRARY_PATH=. gdb --args ./dreerally 
..
Reading symbols from ./dreerally...
(gdb) r

Loading music & effects, please wait..
double free or corruption (!prev)

Program received signal SIGABRT, Aborted.
0xf7fd2b29 in __kernel_vsyscall ()
(gdb) bt
#0  0xf7fd2b29 in __kernel_vsyscall ()
#1  0xf78fab06 in raise () from /usr/lib32/libc.so.6
#2  0xf78e33f5 in abort () from /usr/lib32/libc.so.6
#3  0xf793ef3c in __libc_message () from /usr/lib32/libc.so.6
#4  0xf79471dd in malloc_printerr () from /usr/lib32/libc.so.6
#5  0xf7948eff in _int_free () from /usr/lib32/libc.so.6
#6  0x56591793 in decryptAnimFrame () at dr.c:17287
#7  0x56591bed in openAnimation (animFile=0x565c8479 "SANIM.haf", a2=1, 
    music=1448903823, a4=2, effect=1448903811, onKeyPressExit=1 '\001', 
    screenResolution=120 'x') at dr.c:17446
#8  0x565a0a3e in checkAndOpenAnimation () at dr.c:23532
#9  0x565b3b1a in mainMenu () at dr.c:32549
#10 0x565b4289 in sub_43ACE0 (a1=3.75, a2=1, a3=-10308, args=0x56b11300 "")
    at dr.c:32997
#11 0x565b89e6 in initSystem (fmodMinVersion=3.75, a1=1, a2=0xffffd7bc, 
    args=0x56b11300 "") at dr.c:35933
#12 0x565b8b32 in main (argc=1, argv=0xffffd8a4) at dr.c:36003

Just to clarify, I'm using the official Death Rally data files.

enriquesomolinos commented 4 years ago

you right, try to remove the video files (*.haf files)

In linux there is a lot of errors.

neuromancer commented 4 years ago

It works! :tada: (however there is no keyboard input).

Keep up the great work!

enriquesomolinos commented 4 years ago

Yes, it has a lot of error, but it is a good start.

neuromancer commented 4 years ago

It seems that the linux version won't compile unless you create the Debug directory.

enriquesomolinos commented 4 years ago

Yes, the makefile.linux file tries to create the executable under this directory. In the next release we can change it without problem

enriquesomolinos commented 4 years ago

In the branch 0.3.x the problem is resolved.

cyberbeat commented 3 years ago

I cannot compile under linux:

first problem: the was no -lSDLMain, could be safely removed, I think

But now many other errors:

make -f Makefile.linux gcc -ggdb -m32 -O0 anim.o cars.o circuit.o config.o dr.o drivers.o graphics.o imageUtil.o menus.o raceParticipant.o raceResults.o savegame.o util.o asset/bpaUtil.o asset/haf.o i18n/i18n.o input/input.o mod/mod.o multiplayer/multiplayer.o popup/popup.o portability/portability.o race/3dSystem.o race/pedestrian.o race/powerup.o sfx/sound.o ui/blackMarketScreen.o ui/creditsScreen.o ui/endGameScreen.o ui/hallOfFame.o ui/licenseScreen.o ui/loadSaveGameScreen.o ui/mainScreen.o ui/menu.o ui/prevRaceScreen.o ui/raceResultsScreen.o ui/selectRaceScreen.o ui/shopScreen.o ui/startGameScreen.o util/hash.o -o dreerally -lstdc++ -lglut -lGLU -lGL -lm -lSDL -lc -lfmod-3.75 /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: imageUtil.o:/DreeRally/imageUtil.c:10: multiple definition of choo2Bpk'; dr.o:/DreeRally/dr.c:1059: first defined here /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: imageUtil.o:/DreeRally/imageUtil.c:12: multiple definition ofunk_445928'; anim.o:/DreeRally/anim.c:127: first defined here /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: savegame.o:/DreeRally/savegame.c:8: multiple definition of Str'; dr.o:/DreeRally/dr.c:743: first defined here /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: asset/haf.o:/DreeRally/asset/haf.c:17: multiple definition ofDstBuf'; dr.o:/DreeRally/dr.c:1050: first defined here /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: popup/popup.o:/DreeRally/popup/popup.c:242: multiple definition of bigLetterSpacing_445848'; imageUtil.o:/DreeRally/imageUtil.c:46: first defined here /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: ui/loadSaveGameScreen.o:/DreeRally/ui/loadSaveGameScreen.c:19: multiple definition ofStr'; dr.o:/DreeRally/dr.c:743: first defined here /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: ui/shopScreen.o:/DreeRally/ui/shopScreen.c:17: multiple definition of unk_444160'; ui/blackMarketScreen.o:/DreeRally/ui/blackMarketScreen.c:19: first defined here /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: ui/shopScreen.o:/DreeRally/ui/shopScreen.c:20: multiple definition ofunk_45FDC4'; ui/blackMarketScreen.o:/DreeRally/ui/blackMarketScreen.c:20: first defined here /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: ui/startGameScreen.o:/DreeRally/ui/startGameScreen.c:11: multiple definition of `textureTemp'; graphics.o:/DreeRally/graphics.c:5: first defined here collect2: Fehler: ld gab 1 als Ende-Status zurück make: *** [Makefile.linux:26: dreerally] Fehler 1

Jpxe commented 2 years ago

I tried to compile the latest 0.3 ver today (bb07127) on Linux and I got this error: https://gist.github.com/ToughGuyKunio/606701cbb473293b37b9207b613cf7d6

Is there another branch that is working?

karjonas commented 1 year ago

I managed to get it to compile on Arch Linux. I had to do some minor fixes, see this branch:

https://github.com/karjonas/DreeRally/commits/linuxtest

Sound is disabled, keyboard input is still borked and it crashes randomly so don't expect too much.