From codelite: Right click on the active project icon (in the tree view) -> Settings -> Common Settings -> Linker -> Libraries
and add:
SDL2
(no need to add -l, or .a/.so codelite will fix this for you)
Hit F7 and it should link fine
Eran
Question
I haven't actually been able to use SDL 2.0 on my laptop, so I am reposting the whole post again. Hopefully somebody else can help me, as I am a little desperate.
"Apparently, I don't have SDL installed correctly since a sample program I found in some of the tutorials for SDL 2.0 don't buid correctly.
Mind you, I am using Ubuntu 12.04 as my operating system, used the instructions in the source code of SDL 2.0.3 to install it on my OS, am using CodeLite 5.4, and am using C as my programming language.
Here is the code I try to test:
#include <SDL2/SDL.h>
#include <stdio.h>
int main(int argn,char **argv)
{
if(SDL_Init(SDL_INIT_VIDEO) != 0)
{
fprintf(stderr,"Could not initialize SDL: %s\n", SDL_GetError());
}
printf("SDL Initialized\n");
SDL_Quit();
printf("SDL Shutdown\n");
return 0;
}
However, I get this:
/bin/sh -c 'make -j 1 -e -f Makefile'
----------Building project:[ SDL - Debug ]----------
make[1]: Entering directory `/home/user/Documents/Programming/C/SDL'
gcc -o ./Debug/SDL @"SDL.txt" -L.
./Debug/main.o: In function `main':
/home/user/Documents/Programming/C/SDL/main.c:6: undefined reference to `SDL_Init'
/home/user/Documents/Programming/C/SDL/main.c:8: undefined reference to `SDL_GetError'
/home/user/Documents/Programming/C/SDL/main.c:13: undefined reference to `SDL_Quit'
collect2: ld returned 1 exit status
make[1]: *** [Debug/SDL] Error 1
make[1]: Leaving directory `/home/user/Documents/Programming/C/SDL'
make: *** [All] Error 2
3 errors, 0 warnings
Can someone please explain to me what the issue is and how I can fix it?"
Solution
From codelite: Right click on the active project icon (in the tree view) -> Settings -> Common Settings -> Linker -> Libraries
and add:
SDL2
(no need to add -l, or .a/.so codelite will fix this for you)
Hit F7 and it should link fine
Eran