SDL_mixer SDL_image and SDL_ttf problems

Hi,
I am just starting to learn about SDL. I have found a series of articles
in Linux Format and hve been trying to get some of it to work. I have also
tried to get a piece of code off a website to work but they all seem to
give errors related to one or more of the above.

I am runnning Mandrake Linux 10.1 official and the output from the SDL FAQ
debug info is as follows :

/usr/bin/sdl-config

1.2.7

/usr/lib/libSDL-1.2.so.0.7.0
/usr/lib/libSDL-1.2.so.0
/usr/lib/libSDL_mixer-1.2.so.0.2.3
/usr/lib/libSDL_mixer-1.2.so.0
/usr/lib/libSDLmain.a
/usr/lib/libSDL.a
/usr/lib/libSDL.la
/usr/lib/libSDL.so
/usr/lib/libSDL_net.a
/usr/lib/libSDL_net-1.2.so.0
/usr/lib/libSDL_net-1.2.so.0.0.5
/usr/lib/libSDL_image-1.2.so.0
/usr/lib/libSDL_image-1.2.so.0.1.2
/usr/lib/libSDL_image.a
/usr/lib/libSDL_image.so
/usr/lib/libSDL_mixer.a
/usr/lib/libSDL_mixer.so
/usr/lib/libSDL_net.so
/usr/lib/libSDL_gfx.so.11.0.0
/usr/lib/libSDL_gfx.so.11
/usr/lib/libSDL_gfx.la
/usr/lib/libSDL_gfx.so
/usr/lib/libSDL_gfx.a
/usr/lib/libSDL_image.la
/usr/lib/libSDL_mixer.la
/usr/lib/libSDL_net.la

No errors on compiling using
./configure
make
checkinstall
my PATH is usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games:/usr/lib
/jre-1.4.2_04/bin:/home/norman/bin

/etc/ld.so.conf is :

include ld.so.conf.d/*.conf
/usr/X11R6/lib
/usr/lib/qt3/lib
/usr/lib/wine
/usr/local/lib
/usr/include/SDL
/usr/lib
/usr/include/freetype2
/usr/include
/usr/include/freetype2/freetype/
/usr/include/SDL

and I did run ldconfig as root before starting.

I am launching the compiler with eg :
g++ 01.cpp -o 01A /usr/bin/sdl-config --libs

and the type of errors I get are :

/home/norman/tmp/ccIpi13y.o(.text+0xe9): In function main': : undefined reference toIMG_Load’
collect2: ld returned 1 exit status

or

g++ TroutWars.cpp -o TrWars1 /usr/bin/sdl-config --libs

/home/norman/tmp/ccSzexKB.o(.text+0xde): In function CTWGame::CTWGame()': : undefined reference toTTF_OpenFont’
/home/norman/tmp/ccSzexKB.o(.text+0xfd): In function CTWGame::CTWGame()': : undefined reference toMix_OpenAudio’
/home/norman/tmp/ccSzexKB.o(.text+0x154): In function CTWGame::CTWGame()': : undefined reference toTTF_RenderText_Blended’
/home/norman/tmp/ccSzexKB.o(.text+0x2e1): In function CTWGame::CTWGame()': : undefined reference toMix_LoadMUS’
/home/norman/tmp/ccSzexKB.o(.text+0x2f9): In function CTWGame::CTWGame()': : undefined reference toMix_LoadMUS’
/home/norman/tmp/ccSzexKB.o(.text+0x32d): In function CTWGame::CTWGame()': : undefined reference toMix_LoadWAV_RW’
/home/norman/tmp/ccSzexKB.o(.text+0x47e): In function CTWGame::CTWGame()': : undefined reference toTTF_OpenFont’
/home/norman/tmp/ccSzexKB.o(.text+0x49d): In function CTWGame::CTWGame()': : undefined reference toMix_OpenAudio’
/home/norman/tmp/ccSzexKB.o(.text+0x4f4): In function CTWGame::CTWGame()': : undefined reference toTTF_RenderText_Blended’
/home/norman/tmp/ccSzexKB.o(.text+0x681): In fun

I have libSDL1.2-1.2.7-9mdk
libSDL1.2-devel-1.2.7-7mdk
libSDL_mixer1.2.5-4mdk
libSDL_mixer1.2-devel-1.2.5-4mdk
libSDL_ttf2.0-2.0.6-4mkd
SDL_ttf-devel-2.0.6-1
perl-SDL-1.20.0-10mdk
installed
I have no idea how to proceed further so would someone explain how dumb I
have been and tell me how to fix it?

Thanks,
Norman

You have to add the libraries like so:

gcc blah blah sdl-config -lSDL_image -lSDL_ttf -lSDL_mixer

because sdl-config only includes the base SDL library.

-TomT64

Norman Elliott wrote:>Hi,

I am just starting to learn about SDL. I have found a series of articles
in Linux Format and hve been trying to get some of it to work. I have also
tried to get a piece of code off a website to work but they all seem to
give errors related to one or more of the above.

I am runnning Mandrake Linux 10.1 official and the output from the SDL FAQ
debug info is as follows :

/usr/bin/sdl-config

1.2.7

/usr/lib/libSDL-1.2.so.0.7.0
/usr/lib/libSDL-1.2.so.0
/usr/lib/libSDL_mixer-1.2.so.0.2.3
/usr/lib/libSDL_mixer-1.2.so.0
/usr/lib/libSDLmain.a
/usr/lib/libSDL.a
/usr/lib/libSDL.la
/usr/lib/libSDL.so
/usr/lib/libSDL_net.a
/usr/lib/libSDL_net-1.2.so.0
/usr/lib/libSDL_net-1.2.so.0.0.5
/usr/lib/libSDL_image-1.2.so.0
/usr/lib/libSDL_image-1.2.so.0.1.2
/usr/lib/libSDL_image.a
/usr/lib/libSDL_image.so
/usr/lib/libSDL_mixer.a
/usr/lib/libSDL_mixer.so
/usr/lib/libSDL_net.so
/usr/lib/libSDL_gfx.so.11.0.0
/usr/lib/libSDL_gfx.so.11
/usr/lib/libSDL_gfx.la
/usr/lib/libSDL_gfx.so
/usr/lib/libSDL_gfx.a
/usr/lib/libSDL_image.la
/usr/lib/libSDL_mixer.la
/usr/lib/libSDL_net.la

No errors on compiling using
./configure
make
checkinstall
my PATH is usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games:/usr/lib
/jre-1.4.2_04/bin:/home/norman/bin

/etc/ld.so.conf is :

include ld.so.conf.d/*.conf
/usr/X11R6/lib
/usr/lib/qt3/lib
/usr/lib/wine
/usr/local/lib
/usr/include/SDL
/usr/lib
/usr/include/freetype2
/usr/include
/usr/include/freetype2/freetype/
/usr/include/SDL

and I did run ldconfig as root before starting.

I am launching the compiler with eg :
g++ 01.cpp -o 01A /usr/bin/sdl-config --libs

and the type of errors I get are :

/home/norman/tmp/ccIpi13y.o(.text+0xe9): In function main': : undefined reference toIMG_Load’
collect2: ld returned 1 exit status

or

g++ TroutWars.cpp -o TrWars1 /usr/bin/sdl-config --libs

/home/norman/tmp/ccSzexKB.o(.text+0xde): In function CTWGame::CTWGame()': : undefined reference toTTF_OpenFont’
/home/norman/tmp/ccSzexKB.o(.text+0xfd): In function CTWGame::CTWGame()': : undefined reference toMix_OpenAudio’
/home/norman/tmp/ccSzexKB.o(.text+0x154): In function CTWGame::CTWGame()': : undefined reference toTTF_RenderText_Blended’
/home/norman/tmp/ccSzexKB.o(.text+0x2e1): In function CTWGame::CTWGame()': : undefined reference toMix_LoadMUS’
/home/norman/tmp/ccSzexKB.o(.text+0x2f9): In function CTWGame::CTWGame()': : undefined reference toMix_LoadMUS’
/home/norman/tmp/ccSzexKB.o(.text+0x32d): In function CTWGame::CTWGame()': : undefined reference toMix_LoadWAV_RW’
/home/norman/tmp/ccSzexKB.o(.text+0x47e): In function CTWGame::CTWGame()': : undefined reference toTTF_OpenFont’
/home/norman/tmp/ccSzexKB.o(.text+0x49d): In function CTWGame::CTWGame()': : undefined reference toMix_OpenAudio’
/home/norman/tmp/ccSzexKB.o(.text+0x4f4): In function CTWGame::CTWGame()': : undefined reference toTTF_RenderText_Blended’
/home/norman/tmp/ccSzexKB.o(.text+0x681): In fun

I have libSDL1.2-1.2.7-9mdk
libSDL1.2-devel-1.2.7-7mdk
libSDL_mixer1.2.5-4mdk
libSDL_mixer1.2-devel-1.2.5-4mdk
libSDL_ttf2.0-2.0.6-4mkd
SDL_ttf-devel-2.0.6-1
perl-SDL-1.20.0-10mdk
installed
I have no idea how to proceed further so would someone explain how dumb I
have been and tell me how to fix it?

Thanks,
Norman


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thanks, I tried it but this is what happened :

g++ TroutWars.cpp -o TrWars1 /usr/bin/sdl-config --libs -lSDL_image
-lSDL_ttf -lSDL_mixer

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x67): In function TTF_Init': : undefined reference toFT_Init_FreeType’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x20b): In function
TTF_OpenFontIndexRW': : undefined reference toFT_Open_Face’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x23c): In function
TTF_OpenFontIndexRW': : undefined reference toFT_Set_Char_Size’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x274): In function
TTF_OpenFontIndexRW': : undefined reference toFT_MulFix’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x293): In function
TTF_OpenFontIndexRW': : undefined reference toFT_MulFix’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x2c1): In function
TTF_OpenFontIndexRW': : undefined reference toFT_MulFix’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x2e1): In function
TTF_OpenFontIndexRW': : undefined reference toFT_MulFix’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x301): In function
TTF_OpenFontIndexRW': : undefined reference toFT_MulFix’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x33c): In function
TTF_OpenFontIndexRW': : undefined reference toFT_Set_Pixel_Sizes’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x53e): In function Load_Glyph': : undefined reference toFT_Get_Char_Index’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x55c): In function Load_Glyph': : undefined reference toFT_Load_Glyph’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x7ab): In function Load_Glyph': : undefined reference toFT_Outline_Transform’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x7c7): In function Load_Glyph': : undefined reference toFT_Render_Glyph’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0xb3d): In function
TTF_CloseFont': : undefined reference toFT_Done_Face’

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x2019): In function `TTF_Quit’: :

undefined reference to `FT_Done_FreeType’ collect2: ld returned 1 exit
status

Hope this gives more clues,
Thanks again,
normanOn Tue, 25 Jan 2005 09:23:39 -0800, TomT64 wrote:

Re: SDL_mixer SDL_image and SDL_ttf problems
You have to add the libraries like so:

gcc blah blah sdl-config -lSDL_image -lSDL_ttf -lSDL_mixer

because sdl-config only includes the base SDL library.

-TomT64

Re: SDL_mixer SDL_image and SDL_ttf problems
You have to add the libraries like so:

gcc blah blah sdl-config -lSDL_image -lSDL_ttf -lSDL_mixer

because sdl-config only includes the base SDL library.

-TomT64

Thanks, I tried it but this is what happened :

g++ TroutWars.cpp -o TrWars1 /usr/bin/sdl-config --libs -lSDL_image
-lSDL_ttf -lSDL_mixer

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x67): In function TTF_Init': : undefined reference toFT_Init_FreeType’

“Undefined reference” generally means the linker knows something exists,
but cannot find it to add to the executable. In this case, the function
FT_Init_FreeType is used, directly or indirectly, by your program, but
the linker, ld (which g++ calls), does not know which library this
function is part of.

Since FT_Init_FreeType is a FreeType function (which SDL_ttf inferfaces
with), add -lfreetype to your list of libraries. More general tips follow.

If a library has an unresolved symbol, try calling “ldd” on its dynamic
linkable version. In this case, libSDL_ttf.a is complaining about an
undefined reference. Calling “ldd /usr/lib/libSDL_ttf.so” (.so are
dynamic linkable libraries) will give you a list of libraries it needs,
and where it is currently finding them.

When in doubt, add these libraries to your compilation call.
libSDL_ttf.so depends (on my system) on libfreetype.so.6, so I replace
the “lib” part with “-l”, ignore the ending and the version number, and
arrive at “-lfreetype”. This tells my compiler/linker to also check the
freetype library.

One thing about libraries and link order: each library is usually added
in the order in which it appears on the command line. Each library is
scanned for any symbols which, until now, have been unresolved. These
new symbols may refer to further undefined symbols (i.e. your code
referred to TTF_OpenFont, which in turn needs FT_Open_Face, etc.). These
new symbols are only searched in libraries further on the command line!

Normally, you don’t need to worry about the entire previous paragraph,
but if you’re sure you’ve added the correct libraries, and there are
still undefined references, you may have added them in the wrong order.
Try working out the order with the above paragraph (generally: first the
derived libraries, then the basic libraries), or just trying things out.

Have fun!

Benjamin Deutsch

Re: SDL_mixer SDL_image and SDL_ttf problems
You have to add the libraries like so:

cut <<

-TomT64

Thanks, I tried it but this is what happened :

g++ TroutWars.cpp -o TrWars1 /usr/bin/sdl-config --libs -lSDL_image
-lSDL_ttf -lSDL_mixer

/usr/lib/libSDL_ttf.a(SDL_ttf.o)(.text+0x67): In function TTF_Init': : undefined reference toFT_Init_FreeType’
cut <<
cut <<
Benjamin Deutsch

Well Guys,

I was just about to ammend my last post because one
program did compile.

But then I saw the second reply and tried that suggestion and
was able to get them all working

So with both of the replies you added greatly to my knowledge.
( I have not done C before just some php, javascript and
years ago Visual Basic )
So thanks again.
best wishes,
NormanOn Tue, 25 Jan 2005 22:44:29 +0100, Benjamin Deutsch wrote: