Jump to content
  • Advertisement
Sign in to follow this  
Aluthreney

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.

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


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

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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!

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!