Public Group

# Need Help Setting Up SDL

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

## Recommended Posts

I'm want to start working with SDL, but I need help setting it up. I'm working on Ubuntu with the CodeBlocks IDE. From what little information I was able to gather, (in Codeblocks) I went to Settings -> Compiler and Debugger -> Search Directories. Under the "Compiler" tab I wrote: /usr/include. Under the "Linker" tab I wrote: /usr/include/SDL. When I compile my program the only error I get is: undefined reference to 'SDL Function', so I think I setup the library correctly because it's not giving me the usual "no such file or directory" error, but I don't know. Can anyone explain what I did wrong (or didn't do)?

##### Share on other sites
I'm working in Windows 7, but here's the idea: the "compiler" tab should have the folder containing SDL.h, which is the "include" folder. The "Linker" tab should have the folder containing "SDL.dll", which is the "lib" folder.

Also, make sure in the build settings, in the "Link Libraries" spot, you've added mingw32, SDL_main, and SDL, along with any other libraries you plan on linking.

##### Share on other sites

Also, make sure in the build settings, in the "Link Libraries" spot, you've added mingw32, SDL_main, and SDL, along with any other libraries you plan on linking.

Isn't mingw32 only used in windows OS?

##### Share on other sites
undefined reference is a linker error. Maybe you can add this to your linker options?sdl-config --cflags --libs

##### Share on other sites
I was able to fix the "undefined reference" error, but now I have a new one: cannot find -lsdl_main? What did I do wrong now?

##### Share on other sites
It should be -lSDLmain, but I don't think it makes any difference on Linux.

##### Share on other sites

Also, make sure in the build settings, in the "Link Libraries" spot, you've added mingw32, SDL_main, and SDL, along with any other libraries you plan on linking.

I just solved the problem! You were telling me to add SDL_main and SDL to my link settings, but SDL already invokes SDL_main. SO I deleted SDL_main from my link setting and the errors went away. However, the image that's supposed to appear isn't appearing, but I think that because its saved as a .jpg instead of .bmp.

##### Share on other sites

I just solved the problem! You were telling me to add SDL_main and SDL to my link settings, but SDL already invokes SDL_main. SO I deleted SDL_main from my link setting and the errors went away. However, the image that's supposed to appear isn't appearing, but I think that because its saved as a .jpg instead of .bmp.

Great! I recommend, if you want to use jpg, png, or other image types (yay alpha transparency), get SDL_image! Everything works exactly the same, except you use IMG_Load(char* file) instead of SDL_LoadBMP(char* file), and you use SDL_DisplayFormatAlpha() instead of SDL_DisplayFormat().

##### Share on other sites
Note, SDL_image adds the ability to handle transparency and other image types, but you still use all of SDL functions that you would have used before!

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633691
• Total Posts
3013344
×