PDA

View Full Version : Linker Error with SDL2.0



Boonami
02-07-2014, 11:26 AM
Hello folks,

I was trying to follow the SDL 2.0 tutorial at http://www.freepascal-meets-sdl.net/ . Unfortunately, this tutorial does not provide any information on how to install the sdl libraries on a linux (namely Kubuntu 14.04), so I tried my best to do it myself.

I installed:
- fpc 2.6.2
- SDL 2.0 via "apt-get install libsdl2*"
- Tim Blume's SDL2 units (downloaded the archive, extracted it to /usr/lib/fpc/2.6.2/units/x86_64-linux/sdl2.0)

Now when trying to compile the demo program from chapter 4 (http://www.freepascal-meets-sdl.net/seiten/kapitel/kap4_v2.html, nothing special), I keep getting



boonami@boonami-desktop:~/src/sdltest$ sudo fpc ./test.pas
Free Pascal Compiler version 2.6.2-8 [2014/01/22] for x86_64
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling ./test.pas
Linking test
/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
/usr/bin/ld.bfd: cannot find -lSDL_image-2
test.pas(33,1) Error: Error while linking
test.pas(33,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)


After about half an hour I am ashamed to confess that my google-fu has failed me as well.
The solution for most people was to install the corresponding -dev libraries, I already have that one.


Can somebody help me out?

PS: I was unsure whether to post this to the SDL section or the fpc one, so I decided by coin toss.

Super Vegeta
02-07-2014, 12:14 PM
If you have the -devel packages, everything should work. So either you're still missing a pack (try listing all available *sdl* packages), or the SDL2 units you downloaded have their linking options set up wrong.

Cybermonkey
02-07-2014, 03:58 PM
Yes, seems that libsdl2-image-dev is missing.
Or wait a minute, I think I had to change on Ubuntu the header of sdl2_image.pas.
If it looks like that

{$IFDEF UNIX}
{$IFDEF DARWIN}
IMG_LibName = 'libSDL_image-2.dylib';
{$ELSE}
{$IFDEF FPC}
IMG_LibName = 'libSDL2_image.so';
{$ELSE}
IMG_LibName = 'libSDL2_image-2.so.0';
{$ENDIF}
{$ENDIF}
{$ENDIF}


everything should be allright.

Boonami
04-07-2014, 11:47 AM
Yes, seems that libsdl2-image-dev is missing.
Or wait a minute, I think I had to change on Ubuntu the header of sdl2_image.pas.
If it looks like that

{$IFDEF UNIX}
{$IFDEF DARWIN}
IMG_LibName = 'libSDL_image-2.dylib';
{$ELSE}
{$IFDEF FPC}
IMG_LibName = 'libSDL2_image.so';
{$ELSE}
IMG_LibName = 'libSDL2_image-2.so.0';
{$ENDIF}
{$ENDIF}
{$ENDIF}


everything should be allright.

That was it, thank you! <3

Seems like they changed the file name, or someone wasn't paying attention.