SDL_Init() problem as root

Hi all,

I’m having a strange problem with the SDL_Init() function whilst running my compiled app as root, under the Linux console. However, I have identified that this only happens when another object file is linked. I am using GCC 4.6.3. Here is my code:

init.c

#include <SDL/SDL.h>

void init() {
	// Start SDL
	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
}

void close() {
	// Quit SDL
	SDL_Quit();
}

main.c

#include "init.h"

int main(int argc, char* argv[]) {
	init();
	
	close();
	
	return 0;
}

And here is my Makefile, in case my compile options are incorrect:

# Source files
SOURCES=main.o init.o

# Output binary name
OUTPUT=sdltest

# Flags for compilers
CFLAGS=-c -Wall
LFLAGS=-lSDL

all: $(SOURCES) link

clean:
	rm *.o $(OUTPUT)

link:
	gcc $(SOURCES) $(LFLAGS) -o $(OUTPUT)

All help will be appreciated!

  • NFSGamer

My apologies, I forgot to mention what the problem actually is, and what happens.

I run the app under a root terminal (real terminal, not emulated under X) and the following is written to the screen:

init kbd.
Segmentation fault

However, when running the app as a non-root user I get no output from the application.[/code]