Common Issues when Porting Games - haikuports/haikuports GitHub Wiki
Common issues while porting games to Haiku
Overview
In this page we were talking about the most common issues that you may find if you port a game to Haiku.
Which libraries are supported?
Haiku supports some of the main libraries used by games like:
- SDL (1 and 2)
- Allegro
- Box2D
- PhysFS
- ODE
- GLEW
- Devil
- FreeType
- OpenAL
Haiku also supports OpenGL trough Mesa, but only with a software renderer, so it can be slow.
My OpenGL graphics doesn't show, what am I missing?
Maybe your system doesn't have the driver for Mesa. Haiku only has a software renderer, which is quite slow. You need to install that renderer from HaikuDepot or pkgman.
Package name: mesa_swrast or mesa_x86_swrast
Where are pthreads?
Pthreads are used in the UNIX world in order to manage threads. In Linux systems it is implemented in a library called libpthread.so
. In Haiku however, pthreads are in libroot.so
. Many builds fail because they try to search libpthread.so
instead. You need to fix the build system, trying not to break it for other systems. For example if build system is written in CMake
IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Haiku")
TARGET_LINK_LIBRARIES(MyGame pthread)
ENDIF()
Or in Autoconf
AC_CHECK_LIB([pthread], [pthread_create], [LIBPTHREAD="-lpthread"],
[AC_CHECK_LIB([root], [pthread_create], [LIBPTHREAD="", AC_DEFINE([HAVE_LIBPTHREAD], 1, [Have builtin pthread API])],
[AC_MSG_WARN([Pthread library not found - threads disabled.])])])
Or
AC_SEARCH_LIBS([pthread_create], [pthread root], [], [
AC_MSG_ERROR([unable to find the pthread_create() function])
])
More info about AC_SEARCH_LIBS
And if the game doesn't use a LIBPTHREAD var, create it.
LDFLAGS = -lpng $(LIBPTHREAD)
This may work depending on the game build system
ifneq ($(OSTYPE),haiku)
LDFLAGS += -lpthread
endif
How can I patch a game?
Try building your game with HaikuPorter. When it finishes with an error you can enter the source folder. It is located in a folder inside your recipe folder, usually called work-$portVersion
. Look into the source
folder. Make your fixes there. To try the changes, just run again HaikuPorter. When your game finally builds you can generate a patch. The patch can be used in your recipe to fix the source everytime HaikuPorter runs. Run git add
to add the files that you have modified, then run git commit
and leave a meaningful message. Then run HaikuPorter with the "Extract Patchset" option.
haikuporter -e port_name
It generates a folder in your recipe folder called patches
where your patch lives.
Now add your patch to the recipe.
PATCH="name_of_the_patch.patchset"
How can I add a new license?
Haiku provides a lot of licenses installed under /system/data/licenses
but your game may use a different license.
Create a folder inside your recipe folder called licenses
. Now put inside a license file, the name of the file should be the name of license, no extensions. Then in your recipe just called your license as it appears in your licenses
folder.
How do I make a package which requires GCC4 in GCC2 hybrid systems?
Your game may require GCC4, it may use some C++11 features, but Haiku default image has GCC2 by default. You can generate packages with the secondary architecture system.
First, your recipe file has to have these lines:
ARCHITECTURES="!x86_gcc2 ?x86_64 ?x86"
SECONDARY_ARCHITECTURES="x86"
They say that your package is broken on x86_gcc2 and it's untested under x86 GCC4 and x86_64 (64 bits Haiku). The SECONDARY_ARCHITECTURE says that it can be built, for example, in x86_gcc2 if you use the secondary architecture the system provides.
You need to change all your package PROVIDES, REQUIRES, BUILD_REQUIRES and BUILD_PREREQUIRES to use the secondary architecture properly. Just add $secondaryArchSuffix at the end of every package name.
REQUIRES="
lib:libogg$secondaryArchSuffix
"
Some tools from BUILD_PREREQUIRES work without the suffix, like make
.
BUILD_PREREQUIRES="
cmd:gcc$secondaryArchSuffix
cmd:ld$secondaryArchSuffix
cmd:make
"
Check your HaikuPorter settings (/boot/home/config/settings/haikuports.conf
) and enable the SECONDARY_ARCHITECTURE field if it's disabled.
Now, you can build your package, just append the secondary architecture suffix.
haikuporter mygame_x86
How do I allow a game to have a data directory that is writable?
Your game may want to store configurations or downloaded data. Haiku provides a read-only filesystem but you can make a folder writable if you explicit enable it.
GLOBAL_WRITABLE_FILES="
settings/mygame.conf keep-old
"
This setting allow the game to modify that file and the file already exists, keep it. However, you might need an entire folder.
GLOBAL_WRITABLE_FILES="
settings/download_data directory keep-old
"
You must specify the directory keyword.
How do I add an application icon?
Haiku handles application icon via resource files that are embedded into the executable. On the other hand, Linux icons are defined via Desktop files which is quite different.
First, open your game icon with Icon-O-Matic or create a new icon. Then, you must save your icon as HVIF RDEF. Create a folder called additional-files
inside your recipe folder. Create a file called mygame.rdef
. Later, you have to declare that file by adding the line ADDITIONAL_FILES="mygame.rdef"
to the recipe. Open RDEF with your favourite text editor. You should put something like this:
resource app_flags B_SINGLE_LAUNCH | B_ARGV_ONLY;
resource app_version {
major = 0,
middle = 7,
minor = 4,
variety = B_APPV_FINAL,
internal = 0,
short_info = "OpenArena",
long_info = "An open-source replacement for Quake 3 Arena."
};
resource app_signature "application/x-vnd.openarena";
resource vector_icon {
$"6E636966010500060A04C3F4C39AC2C6C13EC3F4BE86C522C13E0A04C3F4C39A"
$"C2C6C13EC3F4BE86C522C13E060AAECE0EC7BFCA9ACBA1CA9ACBA1CA9ACAE5CA"
$"46CA72C99FC3FBB464BD84C9A5BC54CAA0BD11CA4CBC54CAA0C036BEFFC9BD3F"
$"CA29BEFFC9BDC3FBB829C8F6C9B7C8F6C9B7C89CCA23060AAECE0EC7BFCA9ACB"
$"A1CA9ACBA1CA9ACAE5CA46CA72C99FC3FBB464BD84C9A5BC54CAA0BD11CA4CBC"
$"54CAA0C036BEFFC9BD3FCA29BEFFC9BDC3FBB829C8F6C9B7C8F6C9B7C89CCA23"
$"020AC3E82BCC5B2BBB752BB49CBD59B49CBA0EB49CC03CC0DAC331B9DEC2A4C0"
$"DAC331C181C0E6C181C0E6BA66C090B52EBC8EB490BEC7B5DDBA1DC3E8B7AEBB"
$"C6B7AECC0AB7AED2A2BC8ED22FBA4AD314BECDC675C0E5CD7642C675C0E5C71B"
$"C32EC71BC32ECE05C29BD335BD59D335C037D335BA0E020AC3E82BCC5B2BBB75"
$"2BB49CBD59B49CBA0EB49CC03CC0DAC331B9DEC2A4C0DAC331C181C0E6C181C0"
$"E6BA66C090B52EBC8EB490BEC7B5DDBA1DC3E8B7AEBBC6B7AECC0AB7AED2A2BC"
$"8ED22FBA4AD314BECDC675C0E5CD7642C675C0E5C71BC32EC71BC32ECE05C29B"
$"D335BD59D335C037D335BA0E060A000100023F533F0000000000003F533FC357"
$"1E451C630A000101123F533F0000000000003F533FC3571E451C630117800004"
$"0A000102023F533F0000000000003F533FC3571E451C630A000103123F533F00"
$"00000000003F533FC3571E451C6301178000040A000104023F533F0000000000"
$"003F533FC3571E451C630A000105123F533F0000000000003F533FC3571E451C"
$"630117800004"
};
Change it to fit your game metadata. The HVIF RDEF copy content should be copied inside resource vector_icon
just like the example.
Now, open your recipe file and in the INSTALL section call addResourcesToBinaries
.
addResourcesToBinaries $portDir/additional-files/mygame.rdef $appsDir/MyGame
How do I make it show up in the application menu?
Your game should live in $appsDir, but the application menu doesn't show $appsDir. You need to create a symlink in fact. Just call addAppDeskbarSymlink
addAppDeskbarSymlink $appsDir/MyGame "My Game"
Last parameter is optional, it sets the name of the symlink.
How do I get the Window Title/ Icon Name of an SDL game to show the Game Name instead of Untitled?
This happens when the programmer forgets to set the SDL_WM_SetCaption. Find the location in the source code where the SDL window is created and then add a call to SDL_WM_SetCation, substituting in the text of "Window Title" and "Icon Title".
SDL_WM_SetCaption("Window Title", "Icon Title");
http://sdl.beuc.net/sdl.wiki/SDL_WM_SetCaption
How do I put huge data files into a different .hpkg file from the game?
Two different scenarios. If your game provides the data in a separate source (other ZIP file or other SVN repo) just create a new package with a _data
suffix. Then put mygame_data
as a package requeriment in REQUIRES.
But if your game gives their data files with the code there's another option.
Your game already installed their data files on $dataDir. You can package all content from $dataDir into a separate package.
packageEntries data $dataDir
Then, define custom properties for your _data
package. There must be in the same recipe file.
SUMMARY_data="Data files for my game"
ARCHITECTURES_data="any"
PROVIDES_data="
mygame_data = $portVersion
"
REQUIRES_data="
haiku
"
Now, you can require your data package from your binary package.
REQUIRES="
mygame_data == $portVersion
lib:libogg$secondaryArchSuffix
"
My game tries to install everything under /usr, what should I do?
Haiku doesn't have a /usr folder. If your game uses standard autoconf HaikuPorter can do the work.
runConfigure ./configure
If your game doesn't use Autoconf you must modify the installation parameters. Take a look at $appsDir, $binDir, $manDir, $libDir, $includeDir, $dataDir, $fontsDir in HaikuPorter-BuildRecipes