LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-11-2004, 09:03 AM   #16
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30

No luck I'm afraid, heres the output.
Code:
[unholy@localhost example1]$ gcc example1.c -o example -lSDL -lpthread
example1.c:10:17: SDL.h: No such file or directory
example1.c:13: error: syntax error before '*' token
example1.c: In function `setpixel':
example1.c:15: error: `Uint8' undeclared (first use in this function)
example1.c:15: error: (Each undeclared identifier is reported only once
example1.c:15: error: for each function it appears in.)
example1.c:15: error: `ubuff8' undeclared (first use in this function)
example1.c:16: error: `Uint16' undeclared (first use in this function)
example1.c:16: error: `ubuff16' undeclared (first use in this function)
example1.c:17: error: `Uint32' undeclared (first use in this function)
example1.c:17: error: `ubuff32' undeclared (first use in this function)
example1.c:18: error: syntax error before "color"
example1.c:22: error: `screen' undeclared (first use in this function)
example1.c:28: error: `color' undeclared (first use in this function)
example1.c:28: error: `r' undeclared (first use in this function)
example1.c:28: error: `g' undeclared (first use in this function)
example1.c:28: error: `b' undeclared (first use in this function)
example1.c:34: error: syntax error before ')' token
example1.c:35: error: `y' undeclared (first use in this function)
example1.c:35: error: `x' undeclared (first use in this function)
example1.c:36: error: syntax error before "color"
example1.c:40: error: syntax error before ')' token
example1.c:42: error: syntax error before ')' token
example1.c:43: error: syntax error before "color"
example1.c:47: error: syntax error before ')' token
example1.c:51: error: `SDL_BYTEORDER' undeclared (first use in this function)
example1.c:51: error: `SDL_LIL_ENDIAN' undeclared (first use in this function)
example1.c:67: error: syntax error before ')' token
example1.c:69: error: syntax error before ')' token
example1.c: At top level:
example1.c:84: error: syntax error before '*' token
example1.c: In function `DrawPicture':
example1.c:90: error: `screen' undeclared (first use in this function)
example1.c: In function `main':
example1.c:103: error: `SDL_Surface' undeclared (first use in this function)
example1.c:103: error: `screen' undeclared (first use in this function)
example1.c:104: error: `SDL_Event' undeclared (first use in this function)
example1.c:104: error: syntax error before "event"
example1.c:110: error: `SDL_INIT_VIDEO' undeclared (first use in this function)
example1.c:117: error: `SDL_Quit' undeclared (first use in this function)
example1.c:120: error: `SDL_SWSURFACE' undeclared (first use in this function)
example1.c:120: error: `SDL_ANYFORMAT' undeclared (first use in this function)
example1.c:136: error: `event' undeclared (first use in this function)
example1.c:139: error: `SDL_QUIT' undeclared (first use in this function)
example1.c:143: error: `SDL_KEYDOWN' undeclared (first use in this function)
 
Old 01-11-2004, 09:05 AM   #17
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30
And the paths seem okay.

Code:
[unholy@localhost example1]$ locate libSDL.a
/usr/lib/libSDL.a
 
Old 01-11-2004, 09:41 AM   #18
Pres
Member
 
Registered: Jun 2002
Location: Australia
Distribution: Slack 9.1
Posts: 232

Rep: Reputation: 30
all of that is to do with the header.

Try

#include <SDL/SDL.h> instead of "SDL.h" .... and do it again.

you're just doing an example here the thing is to get things going, not to worry about makefiles.
 
Old 01-11-2004, 09:58 AM   #19
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30
Doing that gives me this output
Code:
[unholy@localhost example1]$ gcc -g -Wall `sdl-config --cflags` `sdl-config --libs` -o example1 example1.c
example1.c: In function `DrawPicture':
example1.c:86: warning: unused variable `r'
example1.c:86: warning: unused variable `g'
example1.c:86: warning: unused variable `b'
example1.c: In function `main':
example1.c:128: warning: unsigned int format, pointer arg (arg 2)
/home/unholy/tmp/ccCOzzDc.o(.text+0x38): In function `setpixel':
/home/unholy/programming/example1/example1.c:23: undefined reference to `SDL_LockSurface'
/home/unholy/tmp/ccCOzzDc.o(.text+0x6a):/home/unholy/programming/example1/example1.c:28: undefined reference to `SDL_MapRGB'
/home/unholy/tmp/ccCOzzDc.o(.text+0x1f6):/home/unholy/programming/example1/example1.c:79: undefined reference to `SDL_UnlockSurface'
/home/unholy/tmp/ccCOzzDc.o(.text+0x27f): In function `DrawPicture':
/home/unholy/programming/example1/example1.c:96: undefined reference to `SDL_Flip'
/home/unholy/tmp/ccCOzzDc.o(.text+0x2a5): In function `main':
/home/unholy/programming/example1/example1.c:110: undefined reference to `SDL_Init'
/home/unholy/tmp/ccCOzzDc.o(.text+0x2b7):/home/unholy/programming/example1/example1.c:111: undefined reference to `SDL_GetError'
/home/unholy/tmp/ccCOzzDc.o(.text+0x2e2):/home/unholy/programming/example1/example1.c:117: undefined reference to `SDL_Quit'
/home/unholy/tmp/ccCOzzDc.o(.text+0x300):/home/unholy/programming/example1/example1.c:120: undefined reference to `SDL_SetVideoMode'
/home/unholy/tmp/ccCOzzDc.o(.text+0x317):/home/unholy/programming/example1/example1.c:122: undefined reference to `SDL_GetError'
/home/unholy/tmp/ccCOzzDc.o(.text+0x3ba):/home/unholy/programming/example1/example1.c:136: undefined reference to `SDL_PollEvent'
collect2: ld returned 1 exit status
 
Old 01-11-2004, 06:38 PM   #20
Pres
Member
 
Registered: Jun 2002
Location: Australia
Distribution: Slack 9.1
Posts: 232

Rep: Reputation: 30
Err well it's a dead givaway there that you did this :

[unholy@localhost example1]$ gcc -g -Wall `sdl-config --cflags` `sdl-config --libs` -o example1 example1.c

rather than this :

gcc example1.c -o example1 -lSDL -lpthread

with the <SDL/SDL.h> style include ... which was my suggestion
 
Old 01-11-2004, 07:23 PM   #21
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30
I do have <SDL/SDL.h> in my code.

Doing this

gcc example1.c -o example1 -lSDL -lpthread

gives me

Code:
[unholy@localhost example1]$ gcc example1.c -o example1 -lSDL -lpthread
/usr//bin/../lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libSDL.a(SDL_x11video.lo)(.text+0x1d): In function `X11_Available':
: undefined reference to `XOpenDisplay'
/usr//bin/../lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libSDL.a(SDL_x11video.lo)(.text+0x2f): In function `X11_Available':
: undefined reference to `XCloseDisplay'
/usr//bin/../lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libSDL.a(SDL_x11video.lo)(.text+0x453): In function `create_aux_windows':
: undefined reference to `XDestroyWindow'
/usr//bin/../lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libSDL.a(SDL_x11video.lo)(.text+0x4ff): In function `create_aux_windows':
: undefined reference to `XCreateWindow'
/usr//bin/../lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libSDL.a(SDL_x11video.lo)(.text+0x528): In function `create_aux_windows':
: undefined reference to `XSelectInput'


//lots more
Would you mind trying to compile the code I posted earlies to see if it compiles on your machine?
 
Old 01-12-2004, 10:49 AM   #22
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
The errors you posted refer to libSDL.a. Seems the linker cannot find the dynamic libs (libSDL.so). Though I guess it should be very well posible to link SDL statically, it is not the way it should be done generally. this may be the problem when the X-lib's are installed dynamically only. How did you install SDL?

When I try to compile the program you posted, I get no errors (only warnings), either using the sdl-config stuff + #include "SDL.h", or using "gcc example1.c -o example1 -lSDL -lpthread" with #include <SDL/SDL.h>. (on Debian)
 
Old 01-12-2004, 01:13 PM   #23
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30
According to the SDL website, mandrake (and slackware) install KDE in non standard folders, so I added these lines to ld.so.conf, as suggested, but still to no avail

/usr/lib
/opt/kde/lib

I installed the libraries from rpms on a CD, which I think came with Linux Mandrake. I am starting to think it is a problem with the OS. Perhaps it is time to go back to SuSE.

libSDL.a resides in /usr/lib

libSDL.so does not turn up when i try to 'locate' it as a normal user. But as root 'locate' does find it.

I have tried therefore to compile as root but the results arent any different.

Perhaps mandrake is a less ideal distro for the developer.
 
Old 01-12-2004, 01:26 PM   #24
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
by unholy
I installed the libraries from rpms on a CD

<cut />

libSDL.a resides in /usr/lib

libSDL.so does not turn up when i try to 'locate' it as a normal user. But as root 'locate' does find it.


from what ive heard and from the questions ive answered before, mandrake is a bit of a nightmare for development purposes

you say you installed rpm's, were they the normal, development, or static-development rpms because the presence of libSDL.a but not libSDL.so make me think youve installed the static-development rather than the development rpm. but i could be wrong as i dont know much about mandrake/rpms
 
Old 01-12-2004, 03:48 PM   #25
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Could it be that the libSDL.so are not readable to normal users?
 
Old 01-12-2004, 03:50 PM   #26
Pres
Member
 
Registered: Jun 2002
Location: Australia
Distribution: Slack 9.1
Posts: 232

Rep: Reputation: 30
Yeah Kev82 is onto something perhaps - did you install the development package but not the runtimes ? I think you need both,
 
Old 01-12-2004, 05:55 PM   #27
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30
These are the contents of the folder I did the rpm -Uhv from
Code:
SDL-1.0.8-1.i386.rpm              SDL_mixer-1.2.5-1.i386.rpm
SDL-1.2.6-1.i386.rpm              SDL_mixer-devel-1.2.5-1.i386.rpm
SDL-devel-1.0.8-1.i386.rpm        SDL_net-1.2.5-1.i386.rpm
SDL-devel-1.2.6-1.i386.rpm        SDL_net-devel-1.2.5-1.i386.rpm
SDL_image-1.2.3-1.i386.rpm        SDL_ttf-2.0.6-1.i386.rpm
SDL_image-devel-1.2.3-1.i386.rpm  SDL_ttf-devel-2.0.6-1.i386.rpm
If libSDL.so wasnt readable to normal users, at least root should have been able to install it. I think maybe Mandrake is the problem. Its a pity. I've tried several distros, and found Mandrake struck the balance the best. But development is a must for me, so perhaps I will try another of the distros I have here on DVD (SuSE 82., Debian Woody Stable, Gentoo, Slackware, Fedora).

Incidentally, rpm -q SDL doesnt turn up anything.
 
Old 06-11-2010, 01:16 AM   #28
tthtlc
LQ Newbie
 
Registered: Aug 2007
Posts: 18

Rep: Reputation: 2
Smile

Sorry for being late, but your code was quite useful for me, thanks for that, and it compiles successfully easily too....due to a few errors you have:

a. Use <SDL.h> instead. Some error output reduced.
b. It is a C++ program, so please use ".cpp" instead of ".c". "gcc" will use different binaries to execute the ".cpp" vs ".c". More errors reduced.
c. After I change "gcc" to "g++" all error got eliminated, so the working commandline is:

g++ `sdl-config --cflags` `sdl-config --libs` mysdl_example.cpp

(where mysdl_example.cpp is the code you posted earlier.)

My env is Ubuntu 9.04).

A good piece of reference code.

Thanks.

PS:

One of the error I got is:

undefined reference to `__gxx_personality_v0'

this was because I had used "gcc" to compile the "xxx.cpp" instead of "g++" - because I thought gcc is intelligent enough to use g++ just by the recognizing the extension is ".cpp". But no:

http://www.network-theory.co.uk/docs...cintro_54.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cant find gcc ryedunn Mandriva 3 09-14-2005 12:32 AM
Trying to program an SDL application but cannot find the SDL.h file:SuSE 9.2&KDevelop pujolasdf Linux - Newbie 4 03-13-2005 07:50 AM
Mandrake cannot find my gcc cajunaggie Linux - Newbie 2 09-30-2004 07:32 AM
Still cant find and use gcc linuxlah Linux - Software 3 06-06-2002 12:14 AM
Cant find GCC manzoor Programming 3 10-12-2001 01:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration