Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Jerrac on August 09, 2009, 09:19:09 pm

Title: Default sdl code won't compile in Code::Blocks
Post by: Jerrac on August 09, 2009, 09:19:09 pm
I am using the default SDL code provided by the SDL wizard in Codeblocks. It will not compile. Keeps giving me "undefined reference" errors for all the SDL_ functions.

I am using Ubuntu 9.04.

If I compile it manually like this:
Quote
david@tux-alteria:~/workspace/ProjectWhite$ g++ `sdl-config --cflags` -c main.cpp
david@tux-alteria:~/workspace/ProjectWhite$ g++ -o main `sdl-config --libs` main.o
It works fine.

How can I get it to find the functions correctly?
Title: Re: Default sdl code won't compile in Code::Blocks
Post by: Jenna on August 09, 2009, 10:39:20 pm
Please post the build log after changing compiler logging to full commandline (change "Settings -> Compiler and debugger... -> Global compiler settings -> [the compiler you use] -> Other settings(rightmost tab)" "Compiler logging" to "Full commandline") .
Title: Re: Default sdl code won't compile in Code::Blocks
Post by: Jerrac on August 09, 2009, 11:10:35 pm
So, this?
Quote
-------------- Build: Debug in ProjectWhite ---------------

g++   -g      -c /home/david/workspace/ProjectWhite/main.cpp -o obj/Debug/main.o
g++  -o bin/Debug/ProjectWhite obj/Debug/main.o     
obj/Debug/main.o: In function `main':
/home/david/workspace/ProjectWhite/main.cpp:15: undefined reference to `SDL_Init'
/home/david/workspace/ProjectWhite/main.cpp:17: undefined reference to `SDL_GetError'
/home/david/workspace/ProjectWhite/main.cpp:22: undefined reference to `SDL_Quit'
/home/david/workspace/ProjectWhite/main.cpp:26: undefined reference to `SDL_SetVideoMode'
/home/david/workspace/ProjectWhite/main.cpp:29: undefined reference to `SDL_GetError'
/home/david/workspace/ProjectWhite/main.cpp:34: undefined reference to `SDL_RWFromFile'
/home/david/workspace/ProjectWhite/main.cpp:34: undefined reference to `SDL_LoadBMP_RW'
/home/david/workspace/ProjectWhite/main.cpp:37: undefined reference to `SDL_GetError'
/home/david/workspace/ProjectWhite/main.cpp:52: undefined reference to `SDL_PollEvent'
/home/david/workspace/ProjectWhite/main.cpp:76: undefined reference to `SDL_MapRGB'
/home/david/workspace/ProjectWhite/main.cpp:76: undefined reference to `SDL_FillRect'
/home/david/workspace/ProjectWhite/main.cpp:79: undefined reference to `SDL_UpperBlit'
/home/david/workspace/ProjectWhite/main.cpp:84: undefined reference to `SDL_Flip'
/home/david/workspace/ProjectWhite/main.cpp:88: undefined reference to `SDL_FreeSurface'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
14 errors, 0 warnings
 
Title: Re: Default sdl code won't compile in Code::Blocks
Post by: Jenna on August 09, 2009, 11:18:34 pm
Did you install the libsdlx.x-dev package after creating the project ?
C::B caches the backticked expressions if they are first used.
If you install the appropriate package after the first use of the expressions, you have to close and reopen C::B (not only the project).
Title: Re: Default sdl code won't compile in Code::Blocks
Post by: Jerrac on August 09, 2009, 11:27:35 pm
Ah, I did install the sdl dev package afterwards. Restarting Codeblocks worked. Thanks!