I have make a first application (An empty Window) with the library SDL2 in C on Haiku BeOS. And I happy about that.
I had Compile and Install the SDL2 library following the Official SDL Website Tutorial.
But in the finaly step, for compiling my SDL2 app with gcc I had must enter a special path (where exactly the library is installed). Like this:
`~/Projects/Hello> gcc main.c -o SDL -I/boot/home/config/non-packaged/include/SDL2 -L/boot/home/config/non-packaged/lib -D_REENTRANT -lSDL2`
… GCC dont find -lSDL2 when I don’t give the full path of the SDL2 library. How can I do for simplify compiling it the next time?
Another question…My SDL2 app can run now but, where is the SDL library (binary like *.DLL on windows)?
I used SDL on Windows before and for distribut a SDL game we must give the binary library with the SDL app.
Thank for reply.
Haiku ships sdl2 packages which can be installed from pkgman, those packages will be installed and setup so you won’t have to specify a path and will be found automatically at runtime.
The runtime package is called libsdl2 and the development package is called libsdl2_devel
Haiku, uses .so (shared object) instead of .dll (dynamic link library).
Please first leanr the directory hirachy of haiku. Always take a look in haikudepot to find needed things.
Thank for this reply that will be helpfull.
Yes I have done a search on Haikudepot but I find a lot of SDL packages mixed and I have prefered to compile it after this search.
Well, yes, there are a lot of different SDL packages, for SDL_net, SDL_mixer, etc. as these are all separate things that can be used with SDL.
Normally you would use sdl-config or pkg-config to discover the correct include paths and linker flags for SDL in a portable way. Sadly, none of the tutorials linked from their official website do this :’(
They go with “I just moved the headers around” or hardcoded paths, which is definitely NOT how you should do things.
Well I had following this step from the Official Website…See here (Unix-like step and Haiku section…):
I have in first time downloaded the sources of SDL2 and after lunch the Terminal in the extracted SDL2 source Dir.
That normally install SDL2 library but not in the same path that HaikuDepot. I just saw now that the configure --prefix command give the directory PATH where to install the library.
I have use the sdl2-config app for find the cflags and the libs but sdl-config say well “-lSDL2” after the manually compilation and installation. But when I was compiling my first App in SDL2 gcc/ld give me an error message ==>Can’t find -lSDL2.
Now I have been uninstalled my manually installation of SDL2 and use the trick from oreo639 (installing the libsdl2_devel from Haikudepot) and that work very well for compiling easilly via -lSDL2 and GCC.