Help: SDL & Anjuta

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
Post Reply
saquib_javed
Naib Subedar
Posts: 344
Joined: Sat Apr 10, 2004 9:07 pm
Location: Karachi
Contact:

Help: SDL & Anjuta

Post by saquib_javed »

Hello

my main.cc file is

Code: Select all

/* Created by Anjuta version 1.0.2 */
/*	This file will not be overwritten */

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

int main()

{
	printf("[Initializing]\n");
	SDL_Surface *screen;
	if( SDL_Init(SDL_INIT_VIDEO) < 0 )
	{
		printf("\tCouldn't initialize SDL: %s\n", SDL_GetError());
		exit(1);
	}
	atexit(SDL_Quit);
	
	return EXIT_SUCCESS;
}
but when i try to compile it it gives error (as follows)

Code: Select all

.
.
.

/bin/sh ./libtool --mode=link c++ -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1 -g -o game main.o
c++ -Wall  -Wimplicit -Wunused -Wmissing-prototypes -O1 -g -o 
main.o: In function `main':
/home/saquib/Projects/Game/src/main.cc:13: undefined reference to 'SDL_Init'
/home/saquib/Projects/Game/src/main.cc:15: undefined reference to 'SDL_GetError'
/home/saquib/Projects/Game/src/main.cc:18: undefined reference to 'SDL_Quit'
collect2: ld returned 1 exit status
make[2]: *** [game] Error 1
make[2]: Target `all' not remade because of errors.

.
.
.
and my system is

[saquib@localhost saquib]$ uname -a
Linux localhost.localdomain 2.4.18-3 #1 Thu Apr 18 07:37:53 EDT 2002 i686 unknown
[saquib@localhost saquib]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)
[saquib@localhost saquib]$ c++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)
[saquib@localhost saquib]$

:?: any1 knows that what is problem here or anything missing :?
Use Linux and feel Free.
OR
Feel free to use Linux. ;)
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Re: Help: SDL & Anjuta

Post by lambda »

you're not linking against the sdl library. add -lSDL or -lsdl to the link line (i can't get to my linux box to check the name of the library).
saquib_javed
Naib Subedar
Posts: 344
Joined: Sat Apr 10, 2004 9:07 pm
Location: Karachi
Contact:

Post by saquib_javed »

so where to make change

i mean what should i do with my project settings
Use Linux and feel Free.
OR
Feel free to use Linux. ;)
jargon
Lieutenant Colonel
Posts: 691
Joined: Mon Oct 13, 2003 9:40 am

Post by jargon »

haven't used anjuta much, but what lamba is saying means that this argument has to be passed to the compiler. So try to find some compiler options dialog in anjuta, something that allows you to alter the flags passed to the compiler or do it manually on the command line.

g++ <blah....> -lSDL <blah...>

e.g.
this is what i did w/ your code:

$: g++ main.cc -o sdlex.exe -lSDL
$: ./sdlex.exe
[Initializing]
$:
jargon
lemon
Naik
Posts: 80
Joined: Wed Aug 07, 2002 8:00 pm
Location: karachi
Contact:

Post by lemon »

gcc -g -o yourbin yourcode.c `sdl-config --cflags --libs` -lSDL_mixer
Wasay Ahmed
B.E. CE SSUET
MBA IBA
saquib_javed
Naib Subedar
Posts: 344
Joined: Sat Apr 10, 2004 9:07 pm
Location: Karachi
Contact:

Post by saquib_javed »

thanX guys

I found the solution on
http://users.vlo.ids.gda.pl/~aragorn/vi ... &article=1
and thats what i wanted to do

thanX lambda
Use Linux and feel Free.
OR
Feel free to use Linux. ;)
Post Reply