Finally! A Raylib Template That Works on AmigaOS 4 Out of the Box

Yes, I’ve done it! I’ve built a template that allows you to build a multi-platform on AmigaOS 4, natively, out-of-the-box. This means no installing of dependencies or other hackery. Just download the code, and build it.

I’ve turned it into a template, which is available in Kea Campus’ Amiga Corner (to Creator and higher members). First though, here’s how I did it…

Summary

The first step is to set up the necessary software, i.e:

Next, I downloaded a prebuilt raylib for AmigaOS 4 binary, along with its dependencies. These are the same binaries used in the previous cross-compiler video.

NOTE: I was unable to unarchive them directly on AmigaOS, and so used my Windows laptop instead.

My strategy is pretty simple: I use precompiled libraries to build raylib projects on AmigaOS. Building on all other OSes is done direct from the source-code using FetchContent.

Here are the files to download:

These are unarchived, and the clib4 subdirectory is copied into the template project’s ThirdParty/AmigaOSLibs/ subdirectory.

NOTE: The *.deb files store the clib4 subdirectory in usr/ppc-amigaos/SDK/local/.

Next, the CMakeLists.txt build script from the previous video needs to be modified. The following code detects that we’re building for AmigaOS:

if(${CMAKE_SYSTEM_NAME} STREQUAL "AmigaOS")
	set(AMIGAOS4 1)
endif()

Next, the AmigaOS4 specific build code:

if(AMIGAOS4)
	set(CMAKE_CXX_FLAGS "-mcrt=clib4 -mstrict-align")
	set(CMAKE_C_FLAGS "-mcrt=clib4 -mstrict-align")
	set(CMAKE_LD_FLAGS "-mcrt=clib4 -athread=native")
	set(CMAKE_EXE_LINKER_FLAGS "-mcrt=clib4 -Wl,--no-undefined -athread=native")
	set(CMAKE_SHARED_LINKER_FLAGS "-mcrt=clib4 -use-dynld -Wl,--no-undefined -athread=native ")
	set(CMAKE_MODULE_LINKER_FLAGS -shared)
	set(CMAKE_SHARED_LINKER_FLAGS -shared)
	include_directories("ThirdParty/AmigaOSLibs/clib4/include")
	link_directories("ThirdParty/AmigaOSLibs/clib4/lib")
	find_package(Threads REQUIRED)
else()
	// Insert regular FetchContent based code to build Raylib 5.5 here
endif()

This tells CMake where to find the prebuilt libraries and include files, as well as setting up various compiler flags.

Finally, after add_executable() we need the following to link to some additional dependencies:

if(AMIGAOS4)
	target_link_libraries(${PROJECT_NAME} glfw3 GL Threads::Threads)
endif()

And that’s all there is to it. The project will now build and run on AmigaOS 4, as well as on Windows, MacOS X, Linux and more. Not perfect, but it works well enough. It allows me to write raylib based apps/games that work on multiple platforms, including AmigaOS.

Raylib on AmigaOS 4, built natively.

Get the Template Code

You can download the template that you saw in this video from the Kea Campus’ Amiga Corner. Click here, and join the Creator or Elite tier to download.

Leave a Comment

Your email address will not be published. Required fields are marked *

 


Shopping Cart
Scroll to Top