Trying to port NXEngine-evo

Hello there! Now that Haiku is in beta, I want to help in some way. Looking through the repos on my machine, I found NXEngine-evo, which has Linux build instructions here. I have installed the required libraries from HaikuDepot, however these errors pop up when running cmake -DCMAKE_BUILD_TYPE=Release .. in the terminal:

CMake Error at /boot/system/data/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find SDL2 (missing: SDL2_INCLUDE_DIR)
Call Stack (most recent call first):
  /boot/system/data/cmake/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  cmake/Modules/FindSDL2.cmake:179 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:14 (find_package)

Additionally, here is the CMakeOutput.log file.

I apologize if this seems trivial to some out there. This is my first time trying to compile programs for Haiku. I want to contribute in some way to Haiku and learn something new; this is something that (if successful) would fulfill both aims.

Probably just a failure on finding the installed sdl2 libraries (development packages).
Best solution is using pkgman as in:

pkgman search sdl

And installing your architecture sdl development packages (probably x86 would be the only one that works).

According to your CMakeOutput.log, it might fail later, as it’s going to compile a pthread test, and might try to compile with -pthread or link with -lpthread. May just keep compiling and working

PS: i like to have more gaming options too :+1:

Running pkgman search sdl | grep "S " shows that the necessary SDL 2 packages are already installed:

S       libsdl2                                Simple Direct Media Layer 2.0                                                   
S       libsdl2_devel                     Simple Direct Media Layer 2.0 (development files)                               
S       sdl2_mixer                         SDL2 mixing library                                                             
S       sdl2_mixer_devel               SDL2 mixing library (development files)                                         
S       sdl2_ttf                               A TrueType font rendering library for SDL2                                      
S       sdl2_ttf_devel                     A TrueType font rendering library for SDL2 (development files)

Note: There are seven spaces between S and the enclosing " in the grep part of the command. Discourse seems to skip displaying more spaces between characters unless they are in a codeblock. Here is the actual command:

pkgman search sdl | grep "S       "

:thinking: i guess that i’m too used to Linux when talking about ‘development packages’. What i meant in Haiku, is that there is no package installed with the sources for sdl2, which should be the ‘source’ suffixed package.

Unfortunately, neither haikudepot nor pkgman can install it for my Haiku version, so… outta luck.
This is kinda the stuff that should be fixed for normal development of apps in Haiku.

Seems like i’m being a Haiku-noob here, as the devel packages do work and generated the include files. Sorry again for noobness.

This is probably related to a misconfiguration on cmake default params

Yep. It starts compiling if you use:

cmake -DCMAKE_BUILD_TYPE=Release -DSDL2_INCLUDE_DIR=/boot/system/develop/headers/x86/SDL2/ -DSDL_MIXER_INCLUDE_DIR=/boot/system/develop/headers/x86/SDL2/ ..

But fails for defines as not being in a known platform and all that.

It is a bit weird that it is complaining about missing files when none of the sort happens in Linux. Maybe it is defaulting to Windows? The original NXEngine was only for Windows until it was later ported to multiple other operating systems and platforms.

Addendum: Output from the compiler

~/nxengine-evo/build> make
Scanning dependencies of target nx
[  1%] Building CXX object CMakeFiles/nx.dir/src/ObjManager.cpp.o
In file included from /boot/home/nxengine-evo/src/ObjManager.cpp:2:
/boot/home/nxengine-evo/src/nx.h:5: SDL.h: No such file or directory
In file included from /boot/home/nxengine-evo/src/nx.h:14,
                 from /boot/home/nxengine-evo/src/ObjManager.cpp:2:
/boot/home/nxengine-evo/src/common/basics.h:5: cstdint: No such file or directory
In file included from /boot/home/nxengine-evo/src/siflib/sif.h:5,
                 from /boot/home/nxengine-evo/src/object.h:3,
                 from /boot/home/nxengine-evo/src/ObjManager.h:4,
                 from /boot/home/nxengine-evo/src/ObjManager.cpp:4:
/boot/home/nxengine-evo/src/siflib/../common/misc.h:4: cstdint: No such file or directory
In file included from /boot/home/nxengine-evo/src/object.h:4,
                 from /boot/home/nxengine-evo/src/ObjManager.h:4,
                 from /boot/home/nxengine-evo/src/ObjManager.cpp:4:
/boot/home/nxengine-evo/src/floattext.h:4: SDL.h: No such file or directory
In file included from /boot/home/nxengine-evo/src/player.h:8,
                 from /boot/home/nxengine-evo/src/ObjManager.cpp:6:
/boot/home/nxengine-evo/src/input.h:4: SDL.h: No such file or directory
In file included from /boot/home/nxengine-evo/src/graphics/sprites.h:9,
                 from /boot/home/nxengine-evo/src/ObjManager.cpp:7:
/boot/home/nxengine-evo/src/graphics/nxsurface.h:5: SDL.h: No such file or directory
In file included from /boot/home/nxengine-evo/src/game.h:7,
                 from /boot/home/nxengine-evo/src/ObjManager.cpp:9:
/boot/home/nxengine-evo/src/TextBox/TextBox.h:4: cstdint: No such file or directory
/boot/home/nxengine-evo/src/TextBox/TextBox.h:6: array: No such file or directory
CMakeFiles/nx.dir/build.make:62: recipe for target 'CMakeFiles/nx.dir/src/ObjManager.cpp.o' failed
make[2]: *** [CMakeFiles/nx.dir/src/ObjManager.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/nx.dir/all' failed
make[1]: *** [CMakeFiles/nx.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
~/nxengine-evo/build> 
1 Like

Not at all. It may ask for preconfigurations done by installed packages in Linux (like pkg-config command ones) or post installation configurations (whatever).

You are compiling in x86_gcc2 arch (gcc2) whereas i provided the paths for x86 architecture. Either remove the x86 part from the cmake paths, or set yourself to use the x86 architecture (gcc7) with:

setarch x86

might need to install the libsdl2_x86 packages then

I normally do compile in x86 architecture because newer gcc and all that.

1 Like

Btw, it will compile succesfully in Haiku Rc1Beta (almost ready image version), and if following the maker instructions for running it, you get the game working.(Nice looking btw).

You need a way to define the __unix__ variable in the cmake compilation. I used my compiler proxy to do so (unreleased, it’s alpha).

The game triggers this on exiting anyway:

https://dev.haiku-os.org/ticket/6400

1 Like

Thanks for the info! I’ll also try it in the x86_64 Haiku beta build to see what happens there.

The issue is FindSDL2.cmake file provided with nxengine. It doesn’t look for files in Haiku-specific paths:

1 Like

Unless there are recipes for x86_64 for libsdl… :thinking: nothing.

Thanks. Good to know the answer to that problem. Guess that a recipe might just take cmake params to solve it, with some sys variables for archs.

In any case @win8linux , good find on a game/engine to port. If you get to pass the variables that the engine expects & the application compiles, you can follow the running instructions and get the engine running

nxengine

2 Likes

I’ve added the necessary changes to the CMake files for the modules in this repo.

Addendum: Looking through HaikuPorts reveals a recipe for NXEngine here in HaikuPorts. However, it uses an older engine. Perhaps I’ll modify it to build the newer NXEngine-evo in lieu of starting from scratch.

1 Like

If it’s the NxEngine but not evo, recipe should be in another directory in the tree. Like scummvm having both folders for libretro and normal scummvm.

What i dont like about this game engine is that (if i am not wrong) looks for a folder ‘data’ where the nx binary is located instead of the current path. (Unless i tested wrongly).

And you shouldnt bundle the engine with the game data, so that should be fixed in the source code too (that should go to original coder or in a code patch, which i dont want to do as first option now hehe)

In the case of NXEngine, the data comes with the engine for three reasons:

  • It is more convenient.
  • The engine is specifically tailor-made for one game (Cave Story).
  • The assets are from freeware, hence they are freely distributable.

That has several problems:

  • Do the licenses match among engine and the game files?
  • You would be polluting the binary folder of your architecture with files that are not exe, nor required for other binaries…
  • The above increases the readonly system size.
  • The game files are freely redistributable.
  • I’m not quite sure with this one, but the game data and the code seem to be deeply integrated with each other. There are even source files made specifically for individual characters.
  • Care to explain a bit more about this one?
  • Licenses are weird, i wouldnt mess with that. You can include a command to download and extract the game, if required.
  • Engine should work from the path it’s run and not where it’s physically located, so you can do a symbolic link to the executable in the game data folder (wherever it is, maybe in your home, your desktop… whatever) and work there. Including this in haiku binaries folder should be a nono. If you look around in your bin directory (/system/bin) you would see that there are only binaries only.
  • Installed packages and binaries and info are treated as readonly and mounted at boot (if i understand correctly), so you may be increasing that somehow. Not sure about this.

But i’m still a newbie on Haiku sys functionality, elders may explain if i’m right or saying nonsense

I agree with your second point. However, I think that it would be best not to deviate too much from upstream when it comes to code and file locations. It makes porting easier.

After getting some help from others, I’ve now been able to get NXEngine-evo up and running on x86_64:

The next things to do are to try the same on x86_gcc2 and x86 and see if it works before making a HaikuPorts recipe.

Update: Confirmed working on x86

Update 2: Doesn’t build on x86_gcc2 even when using the same steps for the other previously working architectures, so the program will be for x86 and x86_64 only.

1 Like

Does it trigger an assertion with the issue #6400 after quiting the engine (or a debugger popup)?

It did if run in console in my version, which may have something to do with the iso version, or may happen on other archs too.