Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )

Advanced DNS Management
New ZoneEdit. New Managment.


Sign Up Now
Reply to this topicStart new topic
> SDL not recognized by Gcc?, when I try to build, it errors...
post Jun 28 2006, 03:28 PM
Post #1


Group: Members
Posts: 32
Joined: 21-February 04
Member No.: 2,431

I installed the latest SDL version from source, and everything built fine.
I then write a quick test app that just initiates SDL to see if all is running OK:
#include "SDL/SDL.h"
#include <stdio.h>

int sdlinit(){
    printf("Initialzing SDL\n");
    printf("Could not initialize SDL: %s.\n", SDL_GetError());
    return 0;

int main(){
    printf("Everything is A-OK. Test over\n");
    return 0;

I create my Makefile:
all: test

test: test.o
    gcc 'sdl-config --libs' test.o -o test

test.o: test.c
    gcc -c 'sdl-config --cflags' test.c

and in the end, I try to make it, and I get this:
gcc -c 'sdl-config --cflags' test.c
gcc: sdl-config --cflags: No such file or directory
test.c: In function `sdlinit':
test.c:6: error: `SDL_INIT_VIDEO' undeclared (first use in this function)
test.c:6: error: (Each undeclared identifier is reported only once
test.c:6: error: for each function it appears in.)
test.c:6: error: `SDL_INIT_TIMER' undeclared (first use in this function)
make: *** [test.o] Error 1

if I run sdl-config from console, it works fine. all libraries are in my PATH, and I ran ldconfig. I have absolutely no idea as to why it is not recognized by the compiler. I am grateful for any help, as I'd really like to get started developing some games.
Go to the top of the page
+Quote Post
post Jul 7 2006, 05:52 AM
Post #2

Its GNU/

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069


Surround sdl-config --cflags with back-ticks .
It's an external app, so you need the shell to substitude its output in.
On line 8 you might want to fprintf() to stderr
And since this is C, line 13 should be int main(void) {
And, lines 6 and 7, there's no need to call SDL_Init twice.
(Just do it once, in your if condition.)
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER)==-1) { <- There was no need for those extra parentheses either.
Also, since sdlinit() takes zero arguments, you should also say int sdlinit(void) {

This was kindly provided by Tuxiscool . (so the credit is not mine smile.gif )

Robert B

ps.: this is what I've found out on IRC channel SDL on freenode.

Robert Becskei
May the source be with us!
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 22nd October 2017 - 05:16 AM