www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D+Ubuntu+SDL_image said undefined reference

reply alisue <alisue.seiga gmail.com> writes:
Hi. I'm new to D and I tried to use D with SDL_image(actually SDL_mixer as
well) but it doesn't work.

I used SDL header of D on "D - porting (http://shinh.skr.jp/d/porting.html)"
and I could build simple SDL application(Only using SDL, not with SDL_image) in
Ubuntu. However when I use SDL_image or SDL_mixer, i got message like below:
--------------------------------------------------------------------------
$ gdc -c hello.d -ISDL
$ gdc -ohello hello.o -lSDL -lSDL_image
hello.o: In function `_Dmain':
hello.d:(.text+0x54): undefined reference to `IMG_GetError'
hello.d:(.text+0x159): undefined reference to `SDL_BlitSurface'
collect2: ld returned 1 exit status
--------------------------------------------------------------------------

The message said 'IMG_GetError/SDL_BlitSurface' doesn't defined in lib however
when I use C++, I could compile and run the program. And when I commented out
'IMG_GetError' and 'SDL_BlitSurface' in my source code, I could compile even I
use 'IMG_Load' function which is in SDL_image :-(

How can I fix this program. I have no idea. Can anyone help me? thanks.

Env:
  Ubuntu 9.10 32bit & 64bit
  gdc 4.2.4
Installed:
  libsdl-1.2-dev
  libsdl-image1.2-dev

p.s.
I could build them on Mac OS X Snow Leopard with DMD. Using SDL.framework and
SDL_image.framework.
Dec 29 2009
parent reply alisue <alisue.seiga gmail.com> writes:
alisue Wrote:

Wow. Solved.

What I did is that compile SDL_video.d and SDL_image.d like:
------------------------------------------------------------------
$ gdc -c hello.d -ISDL
$ gdc -c SDL/SDL_image.d -ISDL
$ gdc -c SDL/SDL_video.d -ISDL
$ gdc -ohello hello.o SDL_image.o SDL_video.o -lSDL -lSDL_image
-----------------------------------------------------------------------

Having no idea but work :-)
Dec 29 2009
parent reply Michael P. <baseball.mjp gmail.com> writes:
alisue Wrote:

 alisue Wrote:
 
 Wow. Solved.
 
 What I did is that compile SDL_video.d and SDL_image.d like:
 ------------------------------------------------------------------
 $ gdc -c hello.d -ISDL
 $ gdc -c SDL/SDL_image.d -ISDL
 $ gdc -c SDL/SDL_video.d -ISDL
 $ gdc -ohello hello.o SDL_image.o SDL_video.o -lSDL -lSDL_image
 -----------------------------------------------------------------------
 
 Having no idea but work :-)
How come you are not using something like rebuild or DSSS? This would help having to avoid things like this. Also, why did you decide not to use Derelict?
Dec 29 2009
parent reply Trass3r <mrmocool gmx.de> writes:
Michael P. schrieb:
 How come you are not using something like rebuild or DSSS?
don't forget xfBuild ;)
Dec 29 2009
parent reply alisue <alisue.seiga gmail.com> writes:
Trass3r Wrote:

 Michael P. schrieb:
 How come you are not using something like rebuild or DSSS?
don't forget xfBuild ;)
Well... Because I haven't heard about them. I knew 'rebuild' and 'DSSS' but I thought it might be too old (For Mac OS X 10.4.... I use Mac OS X 10.6 and Most of time when I try to use package for Mac OS X 10.4 they doesn't take a effort) So I just decide to use Ant(for now using Makefile but in future) and build all of .d file in src directory and manually link to lib. I knew it stupid but could't find the way. What is the best way to do it. Is DSSS not too old? or xfBuild???? P.S. Well... Where can I find some tutorial things? I found some but too old and can't compile. P.S. Derelict... seem good I'll try.
Dec 29 2009
next sibling parent Travis Boucher <boucher.travis gmail.com> writes:
alisue wrote:
 Trass3r Wrote:
 
 Michael P. schrieb:
 How come you are not using something like rebuild or DSSS?
don't forget xfBuild ;)
Well... Because I haven't heard about them. I knew 'rebuild' and 'DSSS' but I thought it might be too old (For Mac OS X 10.4.... I use Mac OS X 10.6 and Most of time when I try to use package for Mac OS X 10.4 they doesn't take a effort) So I just decide to use Ant(for now using Makefile but in future) and build all of .d file in src directory and manually link to lib. I knew it stupid but could't find the way. What is the best way to do it. Is DSSS not too old? or xfBuild???? P.S. Well... Where can I find some tutorial things? I found some but too old and can't compile. P.S. Derelict... seem good I'll try.
http://www.dsource.org/projects The 3 big ones I personally use are dsss, gtkd and derelict. Both gtkd an derelict do runtime linking (ie. dlopen()) and both work well under winderz as well (I test some of my crap in windows once in a while with minimal code changes, just some build cruft).
Dec 30 2009
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 12/30/09 04:14, alisue wrote:
 Trass3r Wrote:

 Michael P. schrieb:
 How come you are not using something like rebuild or DSSS?
don't forget xfBuild ;)
Well... Because I haven't heard about them. I knew 'rebuild' and 'DSSS' but I thought it might be too old (For Mac OS X 10.4.... I use Mac OS X 10.6 and Most of time when I try to use package for Mac OS X 10.4 they doesn't take a effort)
DSSS works with Mac OS X 10.5 at lest.
 So I just decide to use Ant(for now using Makefile but in future) and build
all of .d file in src directory and manually link to lib. I knew it stupid but
could't find the way.

 What is the best way to do it. Is DSSS not too old? or xfBuild????

 P.S.
 Well... Where can I find some tutorial things? I found some but too old and
can't compile.

 P.S.
 Derelict... seem good I'll try.
Dec 30 2009
prev sibling parent Clay Smith <clay.smith.r gmail.com> writes:
alisue wrote:
 Trass3r Wrote:
 
 Michael P. schrieb:
 How come you are not using something like rebuild or DSSS?
don't forget xfBuild ;)
Well... Because I haven't heard about them. I knew 'rebuild' and 'DSSS' but I thought it might be too old (For Mac OS X 10.4.... I use Mac OS X 10.6 and Most of time when I try to use package for Mac OS X 10.4 they doesn't take a effort) So I just decide to use Ant(for now using Makefile but in future) and build all of .d file in src directory and manually link to lib. I knew it stupid but could't find the way. What is the best way to do it. Is DSSS not too old? or xfBuild???? P.S. Well... Where can I find some tutorial things? I found some but too old and can't compile. P.S. Derelict... seem good I'll try.
The easier D build system I've found is CDC, its simple and probably the most portable as well. http://www.dsource.org/projects/cdc dsource.org/projects/derelict There is also Dreadmoon.com, which provides a full linux distro suited for D ;)
Dec 30 2009