[sdl_image] Compile errors on darwin8 with libSDL_image and libPNG

Hi there,
I was using my parents’ Mac today and trying to compile my
(supposedly) portable application to MacOS X and encountered some
problems. The problem is specifically that when making SDL_image, it
complains at one point about:
IMG_png.c:70:17: error: png.h: No such file or directory
And of course, this is just the begining of 10 thousand other similar errors.

Lemme explain how I built my programming environment. First, using
MacOSX, build target is : powerpc-apple-darwin8. Using Xcode and a
terminal to do all the work. Now, I’ve successfully compiled zlib, by
doing make and then copying files *.h into $C/include and copying
libz.a (if i remember right) into $C/lib ($C is short for my
installation directory). Then compiled libPNG with the darwin
makefile, changing install directories and where zlib is to be found
in the header of the makefile, worked fine and installed in $C/ as
well.

libZ and libPNG are now installed correctly (I guess… I hope, I’ve
been doing this for the past couple years!)

Now trying to install libSDL: ./configure --prefix=$C ; make ;
make install (no need of sudo as I am owner of install dir) and it
compiles fine, no trouble and installs fine as well.

Now trying to install libSDL_net: ./configure --prefix=$C ; make
; make install … Finds libSDL fine and compiles perfect, installs
with no complaint.

Then tries to install libSDL_image. Note that both libZ and libPNG
were installed in the respective $C/include and $C/lib, they are
there, I can see them. Running ./configure --prefix=$C gives no
trouble, actually I can see the lines:
checking for sdl-config…
/Users/simon/Desktop/compilation/usr_local.darwin/bin/sdl-config
checking for SDL - version >= 1.2.10… yes
checking for uncompress in -lz… yes
checking for jpeg_CreateDecompress in -ljpeg… no
configure: WARNING: *** Unable to find JPEG library (http://www.ijg.org/)
configure: WARNING: JPG image loading disabled
checking for png_create_read_struct in -lpng… yes
checking for TIFFClientOpen in -ltiff… no
configure: WARNING: *** Unable to find Tiff library
(http://www.remotesensing.org/libtiff/)
configure: WARNING: TIF image loading disabled
configure: creating ./config.status

Note the line that says “-lpng… yes”

Now trying: make
And i get after some time:
[…]
if /bin/sh ./libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME=""
-DPACKAGE_TARNAME="" -DPACKAGE_VERSION="" -DPACKAGE_STRING=""
-DPACKAGE_BUGREPORT="" -DPACKAGE=“SDL_image” -DVERSION=“1.2.5”
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1
-DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLOAD_PNG=1 -DLOAD_BMP=1
-DLOAD_GIF=1 -DLOAD_LBM=1 -DLOAD_PCX=1 -DLOAD_PNM=1 -DLOAD_TGA=1
-DLOAD_XCF=1 -DLOAD_XPM=1 -DLOAD_XV=1 -I. -I. -g -O2
-I/Users/simon/Desktop/compilation/usr_local.darwin/include/SDL
-D_GNU_SOURCE=1 -D_THREAD_SAFE -MT IMG_png.lo -MD -MP -MF
".deps/IMG_png.Tpo" -c -o IMG_png.lo IMG_png.c;
then mv -f “.deps/IMG_png.Tpo” “.deps/IMG_png.Plo”; else rm -f
".deps/IMG_png.Tpo"; exit 1; fi
gcc -DPACKAGE_NAME="" -DPACKAGE_TARNAME="" -DPACKAGE_VERSION=""
-DPACKAGE_STRING="" -DPACKAGE_BUGREPORT="" -DPACKAGE=“SDL_image”
-DVERSION=“1.2.5” -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
-DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLOAD_PNG=1
-DLOAD_BMP=1 -DLOAD_GIF=1 -DLOAD_LBM=1 -DLOAD_PCX=1 -DLOAD_PNM=1
-DLOAD_TGA=1 -DLOAD_XCF=1 -DLOAD_XPM=1 -DLOAD_XV=1 -I. -I. -g -O2
-I/Users/simon/Desktop/compilation/usr_local.darwin/include/SDL
-D_GNU_SOURCE=1 -D_THREAD_SAFE -MT IMG_png.lo -MD -MP -MF
.deps/IMG_png.Tpo -c IMG_png.c -fno-common -DPIC -o .libs/IMG_png.o
IMG_png.c:70:17: error: png.h: No such file or directory

Self explanatory, but I noticed this:
"-I/Users/simon/Desktop/compilation/usr_local.darwin/include/SDL"…
It never says the same without the “/SDL” at the end which is required
to find png.h and possibly other header files.

I haven’t found a way to work around this and I don’t own a mac
myself, so I wont be able to experiment past this sunday, probably
only in a week or two…

So I’m stuck at this point, and could not finish this installation,
SDL_image is now the only library that needs to be compiled so I can
finally see if my application is fully Linux/Windows/MacOSX
compatible!

Thanks for all help in advance,
Simon

Simon wrote:

Self explanatory, but I noticed this:
"-I/Users/simon/Desktop/compilation/usr_local.darwin/include/SDL"…
It never says the same without the “/SDL” at the end which is required
to find png.h and possibly other header files.

I haven’t found a way to work around this and I don’t own a mac
myself, so I wont be able to experiment past this sunday, probably
only in a week or two…

So I’m stuck at this point, and could not finish this installation,
SDL_image is now the only library that needs to be compiled so I can
finally see if my application is fully Linux/Windows/MacOSX
compatible!

You could try something like:
CFLAGS="-Os -I$C/include" ./configure --prefix=$C

Cheers,–
Frank Becker - Need a break? http://criticalmass.sf.net/

You could try something like:
CFLAGS="-Os -I$C/include" ./configure --prefix=$C

Great stuff! Thanks Frank!

Passed ./configure, now compiling as I type… However, just as a
note, it gave me the error that CFLAGS wasn’t a known command, I
believe it has to do more with the fact I’m using tcsh rather than
bash, anyway, using setenv did the trick!

Hmmm, compilation finally got some errors, here’s the end of the ./configure:
checking for jpeg_CreateDecompress in -ljpeg… no
configure: WARNING: *** Unable to find JPEG library (http://www.ijg.org/)
configure: WARNING: JPG image loading disabled
checking for png_create_read_struct in -lpng… yes
checking for TIFFClientOpen in -ltiff… no
configure: WARNING: *** Unable to find Tiff library
(http://www.remotesensing.org/libtiff/)
configure: WARNING: TIF image loading disabled

I do not use neither jpeg nor tiff, so I don’t really care about this,
however, compilation gives this:
/bin/sh ./libtool --tag=CC --mode=link gcc -Os
-I/Users/simon/Desktop/compilation/usr_local.darwin/include
-I/Users/simon/Desktop/compilation/usr_local.darwin/include/SDL
-D_GNU_SOURCE=1 -D_THREAD_SAFE -o libSDL_image.la -rpath
/Users/simon/Desktop/compilation/usr_local.darwin/lib -no-undefined
-release 1.2 -version-info 1:4:1 IMG.lo IMG_bmp.lo IMG_gif.lo
IMG_jpg.lo IMG_lbm.lo IMG_pcx.lo IMG_png.lo IMG_pnm.lo IMG_tga.lo
IMG_tif.lo IMG_xcf.lo IMG_xpm.lo IMG_xv.lo -lpng -lz -ljpeg -ltiff -lz
-L/Users/simon/Desktop/compilation/usr_local.darwin/lib -lSDLmain
-lSDL -Wl,-framework,Cocoa
gcc -dynamiclib -o .libs/libSDL_image-1.2.0.1.4.dylib .libs/IMG.o
.libs/IMG_bmp.o .libs/IMG_gif.o .libs/IMG_jpg.o .libs/IMG_lbm.o
.libs/IMG_pcx.o .libs/IMG_png.o .libs/IMG_pnm.o .libs/IMG_tga.o
.libs/IMG_tif.o .libs/IMG_xcf.o .libs/IMG_xpm.o .libs/IMG_xv.o -lpng
-ljpeg -ltiff -lz
-L/Users/simon/Desktop/compilation/usr_local.darwin/lib -lSDLmain
/Users/simon/Desktop/compilation/usr_local.darwin/lib/libSDL.dylib
-Wl,-framework -Wl,Cocoa -install_name
/Users/simon/Desktop/compilation/usr_local.darwin/lib/libSDL_image-1.2.0.dylib
-Wl,-compatibility_version -Wl,2 -Wl,-current_version -Wl,2.4
/usr/bin/libtool: can’t locate file for: -ljpeg
/usr/bin/libtool: file: -ljpeg is not an object file (not allowed in a library)
/usr/bin/libtool: can’t locate file for: -ltiff
/usr/bin/libtool: file: -ltiff is not an object file (not allowed in a library)
make: *** [libSDL_image.la] Error 1

Strange thing, first thing i see this error (I’ve been using SDL_image
for a long time now), will play and try to fix this, however if you
have any ideas, I’ll be monitoring my emails for responses.

Thanks a lot!
Simon

/usr/bin/libtool: can’t locate file for: -ljpeg
/usr/bin/libtool: file: -ljpeg is not an object file (not allowed in a library)
/usr/bin/libtool: can’t locate file for: -ltiff
/usr/bin/libtool: file: -ltiff is not an object file (not allowed in a library)
make: *** [libSDL_image.la] Error 1

Nope, tried deleting and recompiling from scratch, still getting the
exact same problem…
Even tried removing the optimization “-Os” that Frank suggested, but
with no luck…

Anybody has an idea? I’m sure I could dig in the makefile and tweak
it, but I won’t have much more time to spend on a Mac, as I’m leaving
my parents house in a couple hours. Is there any files you guys would
need to analyse this problem while I’m away from the mac, and try it
again next sunday (or the next one after)? like config.log or
anything else?

Thanks,
Simon

Anybody has an idea?

After investigating a bit I found the following page:
http://www.petercooper.co.uk/archives/000698.html
It says: “[…] I discovered it’s an issue with gcc 3.x. Installing
gcc 4.x from the Tiger DVD Developers Tools fixed it.”

I did verify, gcc -v yields:
Reading specs from /usr/lib/gcc/powerpc-apple-darwin8/4.0.0/specs
Configured with: /private/var/tmp/gcc/gcc-4061.obj~8/src/configure
–disable-checking --prefix=/usr --mandir=/share/man
–enable-languages=c,objc,c++,obj-c++
–program-transform-name=/^[cg][^+.-]*$/s/$/-4.0/
–with-gxx-include-dir=/include/gcc/darwin/4.0/c++
–build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8
–target=powerpc-apple-darwin8
Thread model: posix
gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4061)

And it is Tiger, installed from the CD…
Still investigatin…

Simon

Simon wrote:

/usr/bin/libtool: can’t locate file for: -ljpeg
/usr/bin/libtool: file: -ljpeg is not an object file (not allowed in a library)
/usr/bin/libtool: can’t locate file for: -ltiff
/usr/bin/libtool: file: -ltiff is not an object file (not allowed in a library)
make: *** [libSDL_image.la] Error 1

Nope, tried deleting and recompiling from scratch, still getting the
exact same problem…
Even tried removing the optimization “-Os” that Frank suggested, but
with no luck…

I was cut’n pasting from my build script. The -Os isn’t needed.
Try manually disabling the image types you don’t want.
E.g…:
configure --disable-tif --disable-tif-shared …

Cheers,–
Frank Becker - Need a break? http://criticalmass.sf.net/

Still investigatin…

I bypassed the bug by passing:
–disable-jpg
–disable-jpg-shared
–disable-tif
–disable-tif-shared

Strange that only under Tiger that ./configure can’t disable them correctly.
Anyway, now everything is compiled and installed successfully!

Gimme a sec, gonna try to compile my super compatible program…
[…mins later…]
GREAT! Compilation started after adjusting my make.sh script to use
the correct paths… Typing this while the whole thing compiles…

[…mins later…]
Bouhouhouhou… =(~~~
glut.h is not included on darwin… I think i use it only once, and
will try to get rid of it… other than that my program compiles
fine, just can’t link yet! =(

Anyway, the program is just for my own use and is not yet intended for
distribution or anything like that, not yet mature enough, so I’ll
work on it again another day.

I will save my compiled custom usr_local directory for later compiles!

Thanks for those who followed up to the sad end! :wink:

Simon