HurricanGame / Hurrican

Freeware jump and shoot game created by Poke53280, based on the Turrican game series by Manfred Trenz
61 stars 22 forks source link

[Termux] Linker issue #58

Closed IntinteDAO closed 9 months ago

IntinteDAO commented 10 months ago

Well - I don't know if anyone wants to help me :P

Termux is a Linux environment running on Android. I'd like to port the Hurrican game so that I can play the game (potentially) on Android, although it's probably a version mostly for nerds.

Unfortunately, I have a problem with the linker and don't know how to solve it. Maybe I should write to the Termux developers right away, but maybe it can be solved more easily.

https://bin.0xfc.de/?c727d88e0fca4079#7XwFP6JXebQ3AWMPHqPhydVzJyNnHSvg7DTpto6cVrEq

It seems to me that Hurrican uses SDL2 and there should be no problems. If it uses SDL1.2 then there could potentially be problems because (if I'm not mistaken) SDL1.2 is provided by the SDL2 compatibility layer (sdl12-compat).

But maybe someone has a better understanding of C++ code configuration and compilation than I do.

drfiemost commented 10 months ago

It seems you're not linking to SDL_mixer Hurrican can be compiled both with SDL2 (preferred) and SDL1. In any case you need the corresponding SLD_mixer and SDL_image libraries.

IntinteDAO commented 10 months ago

@drfiemost

Thank you for your reply

Just doesn't Cmake manage this to automatically configure everything to link the application correctly?

While in the case of a makefile (pure) such things are a matter of Make and the appropriate linker flags, in the case of Cmake it seems to be done automatically ...?

Cmake itself finds SDL2 libraries correctly

obraz

IntinteDAO commented 10 months ago

Ok, I fixed it by manually adding libs about linker to CMAKE. I wonder why it can't by default detect it on CMakeLists ...

drfiemost commented 10 months ago

Yes, cmake should handle this automatically:

https://github.com/HurricanGame/Hurrican/blob/67da195a2fea7cb43202626a18f13357ac6adac2/Hurrican/CMakeLists.txt#L559C48-L559C48

I see you have no problems linking with SDL_image, maybe there's something wrong with the SDL_mixer cmake modules on your platform. You can check the CMakeCache.txt file, I have this on Linux:

//Path to a file.
SDL2_MIXER_INCLUDE_DIR:PATH=/usr/include/SDL2

//Path to a library.
SDL2_MIXER_LIBRARY:FILEPATH=/usr/lib/libSDL2_mixer.so
IntinteDAO commented 10 months ago

I was not able to solve this problem with your method, but I found my:

CMake Error at CMakeLists.txt:559:
  Parse error.  Expected a command name, got unquoted argument with text
  "SDL2_MIXER_INCLUDE_DIR="/data/data/com.termux/files/usr/include/SDL2"".
target_link_libraries(${PROJECT_NAME} SDL2 SDL2_image SDL2_mixer)

In short I just add to linker info about SDL.

But I think the CMake file is little broken. https://github.com/HurricanGame/Hurrican/blob/67da195a2fea7cb43202626a18f13357ac6adac2/Hurrican/CMakeLists.txt#L554

I think this else will never be executed, because if SDL2_FOUND is true in main verification, then else should not be executed I think.

I think we can close this issue if you want, because the Termux build can handle just my patch :)

drfiemost commented 10 months ago

But I think the CMake file is little broken.

https://github.com/HurricanGame/Hurrican/blob/67da195a2fea7cb43202626a18f13357ac6adac2/Hurrican/CMakeLists.txt#L554

I think this else will never be executed, because if SDL2_FOUND is true in main verification, then else should not be executed I think.

That's the (legacy) cmake syntax, if SDL2 is found the first block is executed, if not it means that SDL1 has been found (or it would have errored out) and the second block is executed.