Help: SDL & Anjuta

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.

Help: SDL & Anjuta

Postby saquib_javed » Sat Aug 06, 2005 12:29 pm

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. ;)
saquib_javed
Naib Subedar
 
Posts: 344
Joined: Sat Apr 10, 2004 9:07 pm
Website: http://www17.brinkster.com/saquibjaved
Location: Karachi

Re: Help: SDL & Anjuta

Postby lambda » Sat Aug 06, 2005 3:12 pm

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).
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore

Postby saquib_javed » Sat Aug 06, 2005 5:49 pm

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. ;)
saquib_javed
Naib Subedar
 
Posts: 344
Joined: Sat Apr 10, 2004 9:07 pm
Website: http://www17.brinkster.com/saquibjaved
Location: Karachi

Postby jargon » Sat Aug 06, 2005 7:21 pm

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
jargon
Lieutenant Colonel
 
Posts: 691
Joined: Mon Oct 13, 2003 9:40 am

Postby lemon » Sun Aug 07, 2005 7:20 am

gcc -g -o yourbin yourcode.c `sdl-config --cflags --libs` -lSDL_mixer
Wasay Ahmed
B.E. CE SSUET
MBA IBA
lemon
Naik
 
Posts: 80
Joined: Wed Aug 07, 2002 8:00 pm
Website: http://www.geocities.com/cyrix_pk
WLM: wasayahmed@hotmail.com
Yahoo Messenger: cyrix_pk@yahoo.com
AOL: wasayinstead@netscape.net
Location: karachi

Postby saquib_javed » Sun Aug 07, 2005 11:54 am

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. ;)
saquib_javed
Naib Subedar
 
Posts: 344
Joined: Sat Apr 10, 2004 9:07 pm
Website: http://www17.brinkster.com/saquibjaved
Location: Karachi


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron