canonical libtiff problems

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
paulotex
Posts: 19
Joined: Sun Jan 20, 2008 9:28 pm

canonical libtiff problems

Post by paulotex »

I've been struggling to compile libtiff with no success for the last 24h. Perhaps someone can help me with it. I think it involves some autoconf magic. Here it goes:

* First I got the source from libtiff.org: 3.8.2

* Then I did the usuall config/config.sub patch to add the psp allegrex. Ran autoconf.

*

Code: Select all

LDFLAGS="-L`psp-config -p`/lib -lc -lpspuser" ./configure --host=psp --prefix=`psp-config -P` --disable-shared
This _seems_ to work fine.

* make failes with:

Code: Select all

libtool: link: CURRENT `' must be a nonnegative integer
libtool: link: `3:8:2' is not valid version information
* So I patched config/ltmain.sh:

Code: Select all

--- config/ltmain.sh	2006-01-23 18:22:32.000000000 +0000
+++ ../tiff-3.8.2-psp2/config/ltmain.sh	2008-09-21 07:41:34.000000000 +0100
@@ -4711,7 +4711,7 @@
 	  # which has an extra 1 added just for fun
 	  #
 	  case $version_type in
-	  darwin|linux|osf|windows)
+	  darwin|linux|osf|windows|none)
 	    current=`expr $number_major + $number_minor`
 	    age="$number_minor"
 	    revision="$number_revision"
Ran configure again (to recreate libtool) and make.

* This times it fails with:

Code: Select all

/Volumes/Extra/Users/paulo/pspdev/bin/../lib/gcc/psp/4.3.1/../../../../psp/lib/libc.a(lib_a-getopt.o):(.bss+0x4): multiple definition of `optind'
../port/.libs/libport.a(getopt.o):/Users/paulo/Documents/PSP/Apps/Bookr/Arrr/tiff-3.8.2-psp/port/getopt.c:56: first defined here
After lots of research, I found out that it is getting duplicate symbols because during "configure" it could _not_ detect "getopt", so it compiled its own version. But because getopt exists, they are now conflicting.

* The reason configure failed detecting getopt is here, in config.log:

Code: Select all

 psp-gcc -o conftest -g -O2 -Wall -W -I/Users/paulo/include  -L/Users/paulo/pspdev/psp/sdk/lib -lc -lpspuser conftest.c -lm -lc  >&5
/Volumes/Extra/Users/paulo/pspdev/bin/../lib/gcc/psp/4.3.1/../../../../psp/lib/libc.a(_write.o): In function `_write':
libcglue.c:(.text+0x84): undefined reference to `sceIoWrite'
If I remove the last -lc and put -lm _before_ conftest.c, the getopt test compiles fine.

So this is where I'm stuck. How can I tell autoconf to place the libs _before_ the source file? Why is it adding -lc when it is already there? Even if I solve this issue, -lc at the end will bite me again later for sure.

I'm sure this problem has occurred before with other libs based on autotools. How did other developers solve it?

Thanks
paulotex
Posts: 19
Joined: Sun Jan 20, 2008 9:28 pm

Solved!

Post by paulotex »

Sorry to answer my own post, but I solved the problem. In configure.ac, after checking for the fundamental libs (in libtiff, it's just libc and libm), just add:

Code: Select all

dnl For PSPSDK, Make sure we add "-lc -lpspuser" at the end
case "$target" in
     *-psp-*)
	LIBS="$LIBS -lc -lpspuser"
     	;;
     *)
	;;
esac
"make" still breaks in the "tools" folder, but that is fine by me, "make install" installs the libs and the headers just fine.
paulotex
Posts: 19
Joined: Sun Jan 20, 2008 9:28 pm

Summary

Post by paulotex »

Here's the summary, in case any one is interested. This can also be helpfull for other autotools projects:

* Edit config.sub and add the mipsallegrex-psp target.
* Edit ltmain.sh and fix version_type. This fix might break the configure on other systems.
* Edit configure.ac and make sure LIBS has "-lc -lpspuser" at the end.
* Run autoconfig.
* Configure should be run as:

Code: Select all

LDFLAGS="-L`psp-config -p`/lib -lc -lpspuser" ./configure --host=psp --prefix=`psp-config -P` --disable-shared
Here is the complete patch against the tiff-3.8.2. sources:

Code: Select all

--- tiff-3.8.2/config/config.sub	2006-03-21 16:42:49.000000000 +0000
+++ tiff-3.8.2-psp/config/config.sub	2008-09-21 09:24:11.000000000 +0100
@@ -3,7 +3,7 @@
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
-timestamp='2006-02-23'
+timestamp='2008-09-21'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -265,6 +265,7 @@
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
 	| mipstx39 | mipstx39el \
+	| mipsallegrex | mipsallegrexel \
 	| mn10200 | mn10300 \
 	| mt \
 	| msp430 \
@@ -348,6 +349,7 @@
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
 	| mipstx39-* | mipstx39el-* \
+	| mipsallegrex | mipsallegrexel \
 	| mmix-* \
 	| mt-* \
 	| msp430-* \
@@ -878,6 +880,10 @@
 	ps2)
 		basic_machine=i386-ibm
 		;;
+	psp)                                                                    
+               basic_machine=mipsallegrexel-psp                                
+               os=-elf                                                         
+               ;;
 	pw32)
 		basic_machine=i586-unknown
 		os=-pw32
diff -rwBux configure tiff-3.8.2/config/ltmain.sh tiff-3.8.2-psp/config/ltmain.sh
--- tiff-3.8.2/config/ltmain.sh	2006-01-23 18:22:32.000000000 +0000
+++ tiff-3.8.2-psp/config/ltmain.sh	2008-09-21 09:29:24.000000000 +0100
@@ -4711,7 +4711,7 @@
 	  # which has an extra 1 added just for fun
 	  #
 	  case $version_type in
-	  darwin|linux|osf|windows)
+	  darwin|linux|osf|windows|none)
 	    current=`expr $number_major + $number_minor`
 	    age="$number_minor"
 	    revision="$number_revision"
diff -rwBux configure tiff-3.8.2/configure.ac tiff-3.8.2-psp/configure.ac
--- tiff-3.8.2/configure.ac	2006-03-23 14:36:40.000000000 +0000
+++ tiff-3.8.2-psp/configure.ac	2008-09-21 11:49:28.000000000 +0100
@@ -92,6 +93,15 @@
         ;;
 esac
 
+dnl For PSPSDK, Make sure we add -lpspuser at the end
+case "$target" in
+     *-psp-*)
+	LIBS="$LIBS -lc -lpspuser"
+     	;;
+     *)
+	;;
+esac
+
 dnl Checks for header files.
 AC_CHECK_HEADERS([assert.h fcntl.h limits.h malloc.h search.h sys/time.h unistd.h])
And here is my compile&install session:

Code: Select all

$ tar xzf tiff-3.8.2.tar.gz
$ cd tiff-3.8.2
$ patch -p1 <../libtiff.diff 
patching file config/config.sub
patching file config/ltmain.sh
patching file configure.ac
$ autoconf
$ LDFLAGS="-L`psp-config -p`/lib -lc -lpspuser" ./configure --host=psp --prefix=`psp-config -P` --disable-shared
...
$ make
...
bmp2tiff.o&#58; In function `main'&#58;
/Users/paulo/Documents/PSP/Apps/Bookr/Arrr/tiff-3.8.2/tools/bmp2tiff.c&#58;781&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `__ctype_ptr'
collect2&#58; ld returned 1 exit status
make&#91;1&#93;&#58; *** &#91;bmp2tiff&#93; Error 1
make&#58; *** &#91;all-recursive&#93; Error 1
$ make install
...
bmp2tiff.o&#58; In function `main'&#58;
/Users/paulo/Documents/PSP/Apps/Bookr/Arrr/tiff-3.8.2/tools/bmp2tiff.c&#58;781&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `__ctype_ptr'
collect2&#58; ld returned 1 exit status
make&#91;1&#93;&#58; *** &#91;bmp2tiff&#93; Error 1
make&#58; *** &#91;install-recursive&#93; Error 1
The errors during make and install are on the tools. The lib is fine.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Adding -G0 to the CFLAGS should remove the __ctype_ptr warnings.
paulotex
Posts: 19
Joined: Sun Jan 20, 2008 9:28 pm

Post by paulotex »

Insert_witty_name wrote:Adding -G0 to the CFLAGS should remove the __ctype_ptr warnings.
duh! Thanks! This is everywhere to be found, I was so obsessed with other errors that I overlooked this. With this flag the compilation of the tools advance quite well until:

Code: Select all

Making all in iptcutil
if psp-gcc -DHAVE_CONFIG_H -I. -I. -I../../libtiff -I../../libtiff -I../../libtiff  -I/Users/paulo/include   -G0 -Wall -W -MT iptcutil.o -MD -MP -MF ".deps/iptcutil.Tpo" -c -o iptcutil.o iptcutil.c; \
	then mv -f ".deps/iptcutil.Tpo" ".deps/iptcutil.Po"; else rm -f ".deps/iptcutil.Tpo"; exit 1; fi
iptcutil.c&#58;8&#58;20&#58; error&#58; memory.h&#58; No such file or directory
make&#91;2&#93;&#58; *** &#91;iptcutil.o&#93; Error 1
But as I told before, having the lib is all I needed.

Thanks for the info!
Post Reply