Segmentation Fault
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?
anyone? I'm compiling it like this:
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?
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?
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.
sure. i tried with your line, still the same behaviour.
no matter how i build it, results in this output:
(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]
#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]
This might sound strange, but try rebooting it. I've read a few SDL problems are solved with a reboot (e.g. this one, this one, etc).
thanks, but i've rebooted countless times
[Edited by - Funkymunky on December 30, 2008 12:56:40 AM]
[Edited by - Funkymunky on December 30, 2008 12:56:40 AM]
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement