Jump to content
  • Advertisement
Sign in to follow this  
Chisser98

[SOLVED]SDL_ttf 'undefined reference'

This topic is 2836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys,

I'm having a heck of a time with SDL_ttf. I downloaded the source and compiled it into a static .a library. Compiled fine.

I then linked to the .a file and included the SDL_ttf.h file in my project (I included the SDL_ttf.h file in one of the classes). However, I keep getting errors when compiling. I also linked to the freetype .a library in my /usr/libs directory, but to no avail.

Here is my console output:

**** Build of configuration Debug for project AITest ****

make all
Building target: AITest
Invoking: GCC C++ Linker
g++ -L/home/jarrett/workspace/angelscript-2.20.1/Debug -o"AITest" ./src/game/world/Locale.o ./src/game/world/Location.o ./src/game/world/World.o ./src/game/Actor.o ./src/game/Civilian.o ./src/game/Game.o ./src/game/Player.o ./src/common/xml/Parser.o ./src/common/terrain/Terrain.o ./src/common/terrain/TerrainMgr.o ./src/common/sdl_wrapper/SDLEventHandler.o ./src/common/sdl_wrapper/SDLFontUtilities.o ./src/common/sdl_wrapper/SDLImageUtilities.o ./src/common/physics/BoxObject2D.o ./src/common/physics/World2D.o ./src/common/objects/GameObject.o ./src/common/logging/Logger.o ./src/common/io/File.o ./src/common/io/Util.o ./src/common/console/Console.o ./src/common/console/ConsoleWindow.o ./src/common/as_wrapper/AngelScript.o ./src/common/as_wrapper/AngelScriptWrapper.o ./src/common/ai/mind/events/Event.o ./src/common/ai/mind/events/EventManager.o ./src/common/ai/mind/Action.o ./src/common/ai/mind/Belief.o ./src/common/ai/mind/Character.o ./src/common/ai/mind/Desire.o ./src/common/ai/mind/Effect.o ./src/common/ai/mind/Goal.o ./src/common/ai/mind/Mind.o ./src/common/ai/brain/Brain.o ./src/common/ai/brain/DecisionCenter.o ./src/common/ai/brain/EmotionCenter.o ./src/common/ai/brain/MemoryCenter.o ./src/common/ai/brain/MoraleCenter.o ./src/common/ai/brain/ReasoningCenter.o ./src/common/ai/brain/SurvivalInstinct.o -lSDL -lfreetype -lSDL_ttf-2.0.10 -langelscript-2.20.1 -lSDL_image -lSDLmain
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `TTF_Init':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:358: undefined reference to `FT_Init_FreeType'
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `TTF_OpenFontIndexRW':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:436: undefined reference to `FT_Open_Face'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:448: undefined reference to `FT_Set_Char_Size'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:472: undefined reference to `FT_Set_Pixel_Sizes'
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `Load_Glyph':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:592: undefined reference to `FT_Get_Char_Index'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:594: undefined reference to `FT_Load_Glyph'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:656: undefined reference to `FT_Outline_Transform'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:662: undefined reference to `FT_Get_Glyph'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:663: undefined reference to `FT_Stroker_New'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:667: undefined reference to `FT_Stroker_Set'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:668: undefined reference to `FT_Glyph_Stroke'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:669: undefined reference to `FT_Stroker_Done'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:671: undefined reference to `FT_Glyph_To_Bitmap'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:673: undefined reference to `FT_Done_Glyph'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:679: undefined reference to `FT_Render_Glyph'
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:880: undefined reference to `FT_Done_Glyph'
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `TTF_CloseFont':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:913: undefined reference to `FT_Done_Face'
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `TTF_GlyphIsProvided':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:1018: undefined reference to `FT_Get_Char_Index'
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `TTF_SizeUNICODE':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:1167: undefined reference to `FT_Get_Kerning'
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `TTF_RenderUNICODE_Solid':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:1383: undefined reference to `FT_Get_Kerning'
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `TTF_RenderUNICODE_Shaded':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:1639: undefined reference to `FT_Get_Kerning'
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `TTF_RenderUNICODE_Blended':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:1887: undefined reference to `FT_Get_Kerning'
/usr/local/lib/libSDL_ttf-2.0.10.a(SDL_ttf.o): In function `TTF_Quit':
/home/jarrett/workspace/SDL_ttf-2.0.10/Debug/../SDL_ttf.c:2044: undefined reference to `FT_Done_FreeType'
collect2: ld returned 1 exit status
make: *** [AITest] Error 1


Does anyone have any clue what is going on??

I'm using Ubuntu and Eclipse. Freetype version 2.4, SDL_ttf version 2.0.10.

I appreciate any help you guys can offer!

Cheers

Jarrett

Share this post


Link to post
Share on other sites
Advertisement
Do you use a Makefile/Makefile.am? If yes, can you post it here?
Or did you setup the Eclipse project as a C++ Executable? (if yes, I can't help much because I never used Eclipse to fully manage the building)

Share this post


Link to post
Share on other sites
Hey aeroz,

Thanks for replying :D

I created the project in CDT Eclipse as an 'Executable empty project', and Eclipse fully manages the building :S It does generate a makefile, but it has plenty of variables that are defined by Eclipse...I'll post it anyway, hopefully it will help..


################################################################################
# Automatically-generated file. Do not edit!
################################################################################

-include ../makefile.init

RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include subdir.mk
-include src/game/world/subdir.mk
-include src/game/subdir.mk
-include src/common/xml/subdir.mk
-include src/common/terrain/subdir.mk
-include src/common/sdl_wrapper/subdir.mk
-include src/common/physics/subdir.mk
-include src/common/objects/subdir.mk
-include src/common/logging/subdir.mk
-include src/common/io/subdir.mk
-include src/common/console/subdir.mk
-include src/common/as_wrapper/subdir.mk
-include src/common/ai/mind/events/subdir.mk
-include src/common/ai/mind/subdir.mk
-include src/common/ai/brain/subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables

# All Target
all: AITest

# Tool invocations
AITest: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker'
g++ -L/home/jarrett/workspace/angelscript-2.20.1/Debug -o"AITest" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

# Other Targets
clean:
-$(RM) $(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) AITest
-@echo ' '

.PHONY: all clean dependents
.SECONDARY:

-include ../makefile.targets




Do you use a Makefile/Makefile.am? If yes, can you post it here?
Or did you setup the Eclipse project as a C++ Executable? (if yes, I can't help much because I never used Eclipse to fully manage the building)

Share this post


Link to post
Share on other sites
Somehow you have to add the library to the project.
Have you tried Project=>Properties=>C/C++ Build=>Settings=>GCC C++ Linker=>Libraries, add "SDL_ttf" to the -l box and the path to the library file to -L.
Is there a reason not using SDL-ttf as a shared library? In most GNU/Linux distros the SDL-ttf package is very easy to install.

Share this post


Link to post
Share on other sites
Hmm

The SDL_ttf library is already added to the c++ linker library (-l), as well as the path to the library (-L). I tried compiling it as a shared (.so) library, but got the same errors.

I *think* the problem has something to do with the freetype library...it looks like the errors it's spitting out when I compile my project (the one that uses the SDL_ttf library) is saying that the SDL_ttf.c class can't find certain freetype methods (however, when I compile the SDL_ttf source code I get no such errors). That's why I tried including the freetype library to my project as well, but to no avail.

I believe you when you say the SDL-ttf package is typically easy to install, that's what makes this so frustrating :D

I think I'll try a pre-compiled version of SDL_ttf and see if that works


Somehow you have to add the library to the project.
Have you tried Project=>Properties=>C/C++ Build=>Settings=>GCC C++ Linker=>Libraries, add "SDL_ttf" to the -l box and the path to the library file to -L.
Is there a reason not using SDL-ttf as a shared library? In most GNU/Linux distros the SDL-ttf package is very easy to install.

Share this post


Link to post
Share on other sites
HAH

Okay, so I found that SDL_ttf was already installed via aptitude, and I found the library in /usr/libs. I linked to that SDL_ttf library and *TADA!*, it works!

Still have no freaking idea what I did wrong, but it's working now (albeit with an older version of SDL_ttf, but who cares)..

Thanks for trying to help me with this one aeroz, I appreciate it.

Cheers


Hmm

The SDL_ttf library is already added to the c++ linker library (-l), as well as the path to the library (-L). I tried compiling it as a shared (.so) library, but got the same errors.

I *think* the problem has something to do with the freetype library...it looks like the errors it's spitting out when I compile my project (the one that uses the SDL_ttf library) is saying that the SDL_ttf.c class can't find certain freetype methods (however, when I compile the SDL_ttf source code I get no such errors). That's why I tried including the freetype library to my project as well, but to no avail.

I believe you when you say the SDL-ttf package is typically easy to install, that's what makes this so frustrating :D

I think I'll try a pre-compiled version of SDL_ttf and see if that works

[quote name='aeroz' timestamp='1299443848' post='4782525']
Somehow you have to add the library to the project.
Have you tried Project=>Properties=>C/C++ Build=>Settings=>GCC C++ Linker=>Libraries, add "SDL_ttf" to the -l box and the path to the library file to -L.
Is there a reason not using SDL-ttf as a shared library? In most GNU/Linux distros the SDL-ttf package is very easy to install.

[/quote]

Share this post


Link to post
Share on other sites
Cool that it's working!


I *think* the problem has something to do with the freetype library...

This could be the cause of the problem. You need to link (statically too, maybe?) the freetype library to your project.


I believe you when you say the SDL-ttf package is typically easy to install, that's what makes this so frustrating :D

Installing is easy but linking not always :D. Did you specify the path /usr/libs manually or has the system detected the library automatically? (what should be the case I think)

Share this post


Link to post
Share on other sites

[quote name='Chisser98' timestamp='1299449890' post='4782571']
I *think* the problem has something to do with the freetype library...

This could be the cause of the problem. You need to link (statically too, maybe?) the freetype library to your project.
[/quote]

That's what I thought too. I linked to the freetype library in my project, but no dice. Interestingly, when I link to the SDL_ttf library in /usr/libs it doesn't complain about undefined references of freetype methods, and it also does not require me to link to the freetype library.

freakin weird man


Did you specify the path /usr/libs manually or has the system detected the library automatically? (what should be the case I think)


It works without me manually specifying the path.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!