user1930037
user1930037

Reputation: 1

How to cross compile SDL2 sources on Windows for Linux

I can cross compile a hello world program on Windows with Linux (Raspberry OS) as the target using gcc for raspberryPI 5 (https://gnutoolchains.com/raspberry/). It runs all ok on the PI target.

But I am not able to do the same for the sources of the SDL2 (Simple DirectMedia Layer) library.

I tried to compile the SDL2 sources on my Windows machine using the same process (with the intention to use them on the PI target). However, I discovered that all examples to build SDL2 use a Linux environment using Cmake and the tool (batch file?) 'configure'. I can use Cmake on windows but it doesn't knows 'configure'. I also thought about copying the already installed SDL2 libs on the RaspberryPI (they are already installed, out of the box) from the RapberryPI to my Windows machine and use it in the link process but that will create a version nightmare and I also don't know if this is possible anyhow.

Am i going in the right direction to build a SDL2 lib this way, or should I consider the possibility of x-compiling SDL2 from Windows to Linux as 'not supported'? I already tried compiling the sources using Eclipse but I can't figure out the correct compiler options and symbols (-D) to get it to work for my PI5 target.

I know that it is possible from a technical point of view, but I don't know if it is from a configuration point of view.

Upvotes: -1

Views: 42

Answers (1)

user1930037
user1930037

Reputation: 1

I solved it by using the RaspberryPI as the build server to build the SDL2 libs from scratch. By using the make and ./configure as provided by https://www.libsdl.org/. Then I copied the generated libs and include files to my Windows machine where I use them in Eclipse CDT to cross compile my application sources and link with the SDL libs.

So, I 'cheated' a little by building on Linux instead of X-compiling all SDL sources on a Windows machine. But I'm happy with the result.

Upvotes: 0

Related Questions