The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_Init() problem as root
NFSGamer


Joined: 11 Jun 2013
Posts: 2
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
Code:

#include <SDL/SDL.h>

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

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


main.c
Code:

#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:
Code:

# 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
NFSGamer


Joined: 11 Jun 2013
Posts: 2
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:
Code:

init kbd.
Segmentation fault


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