Jump to content
  • Advertisement
Sign in to follow this  
Funkymunky

Segmentation Fault

This topic is 3581 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 just got an Asus EEE PC 2G surf. I decided to try a little SDL programming, so after learning about repositories and getting the -dev branch of the libsdl stuff, i wrote a barebones program which calls SDL_Init and SDL_Quit. It gives a "Segmentation Fault" error on SDL_Init(SDL_INIT_VIDEO). Everything else (except of course SDL_INIT_EVERYTHING) returns 0, but that has an error before it even returns. I'm brand new to this. Can anyone offer me any assistance?

Share this post


Link to post
Share on other sites
Advertisement
anyone? I'm compiling it like this:

g++ -o MyProgram main.c -lSDL

but it still just gives a Segmentation Fault before it even returns from SDL_Init. Other programs, that I did not write, can succesfully use SDL. Can anyone point me in any kind of direction as to how to get started with this library?

Share this post


Link to post
Share on other sites
Quote:
Original post by Funkymunky
anyone? I'm compiling it like this:

g++ -o MyProgram main.c -lSDL

but it still just gives a Segmentation Fault before it even returns from SDL_Init. Other programs, that I did not write, can succesfully use SDL. Can anyone point me in any kind of direction as to how to get started with this library?


Try g++ -o MyProgram main.c `sdl-config --cflags --libs` (note: these are backticks, not single quotes). This is assuming the sdl-config script is in your path. If that doesn't help, please try posting the full source code, or a minimal example that displays this behaviour.

Also, while the compiler should definitely not care, ".c" extensions are typically used for C source code, not C++. C++ source code files often have one of the following extensions: .cc, .C (note: uppercase, often found on case sensitive file systems), .cxx, .cpp.

Share this post


Link to post
Share on other sites
sure. i tried with your line, still the same behaviour.


#include <SDL/SDL.h>
#include <stdio.h>

int main(void)
{
int i;

printf("...\n");

i = SDL_Init(SDL_INIT_VIDEO);

printf("%i\n", i);

SDL_Quit();

return 0;
}


no matter how i build it, results in this output:

Quote:
...
Segmentation fault


(but again anything besides SDL_INIT_VIDEO and SDL_INIT_EVERYTHING returns 0 and works fine)

[Edited by - Funkymunky on December 29, 2008 11:49:39 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Funkymunky
thanks, but i've rebooted countless times


Heh, I guessed that but it was worth a shot :-)

I would suggest running the program in a debugger to get a stack trace/more information. You could also try using strace to see what it's doing before the segfault, but a debugger would be the ultimate solution.

Share this post


Link to post
Share on other sites
doh it's specifically related to the debian sdl package, i have to make a slight mod and build from source. thanks for trying to help me, please excuse me for being off base

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!