Mailing List Archive

cross-compiling to mipsel
I hope this mailing list is suitable, because it might be that my probem
is due to a libtool bug.

I try to cross-compile libgcrypt for a mipsel host in a buildroot like
environment. It works fine, except on machines with a host version of
libgpg-error installed in /usr/lib/ (libgpg-error was configured with
--prefix=/usr, but installed into the
$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib).

My configure looks like this:

PATH=$(TARGET_TOOLCHAIN_PATH) \
CFLAGS="$(TARGET_CFLAGS)" \
CPPFLAGS="-I$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/include" \
LDFLAGS="-L$(TARGET_TOOLCHAIN_STAGING_DIR)/lib
-L$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib" \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--program-prefix="" \
--program-suffix="" \
--prefix=/usr \
--sysconfdir=/etc \
--disable-nls \
--disable-largefile \
--enable-shared \
--enable-static \
--disable-rpath \
--disable-asm \
--with-gpg-error-prefix="$(TARGET_TOOLCHAIN_STAGING_DIR)/usr"

If there is libgpg-error installed on the build machine, make stops
while linking:

/bin/sh ../libtool --tag=CC --mode=link mipsel-linux-gcc -Os -W -Wall
-pipe -march=4kc -Wa,--trap -Wall
-L/var/tmp/ds-0.2/toolchain/gcc-4.0.1-uClibc-0.9.26/mipsel-linux-uclibc/lib
-L/var/tmp/ds-0.2/toolchain/gcc-4.0.1-uClibc-0.9.26/mipsel-linux-uclibc/usr/lib
-o libgcrypt.la -rpath /usr/lib -Wl,--version-script=./libgcrypt.vers
-version-info 13:1:2 libgcrypt_la-misc.lo libgcrypt_la-global.lo
libgcrypt_la-sexp.lo libgcrypt_la-stdmem.lo libgcrypt_la-secmem.lo
libgcrypt_la-missing-string.lo libgcrypt_la-module.lo
libgcrypt_la-ath.lo ../cipher/libcipher.la ../mpi/libmpi.la -lgpg-error
-lnsl -lnsl
mipsel-linux-gcc -shared .libs/libgcrypt_la-misc.o
.libs/libgcrypt_la-global.o .libs/libgcrypt_la-sexp.o
.libs/libgcrypt_la-stdmem.o .libs/libgcrypt_la-secmem.o
.libs/libgcrypt_la-missing-string.o .libs/libgcrypt_la-module.o
.libs/libgcrypt_la-ath.o -Wl,--whole-archive ../cipher/.libs/libcipher.a
../mpi/.libs/libmpi.a -Wl,--no-whole-archive
-L/var/tmp/ds-0.2/toolchain/gcc-4.0.1-uClibc-0.9.26/mipsel-linux-uclibc/lib
-L/var/tmp/ds-0.2/toolchain/gcc-4.0.1-uClibc-0.9.26/mipsel-linux-uclibc/usr/lib
/usr/lib/libgpg-error.so -lnsl -march=4kc
-Wl,--version-script=./libgcrypt.vers -Wl,-soname -Wl,libgcrypt.so.11 -o
.libs/libgcrypt.so.11.2.1
/usr/lib/libgpg-error.so: could not read symbols: File in wrong format

Of course /usr/lib/libgpg-error.so is in wrong format. Is there a way to
tell libtool not to use host libraries when cross-compiling?

Is this a common libtool issue or a particular libgcrypt problem?

Regards,

Daniel


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: cross-compiling to mipsel [ In reply to ]
On Sun, 19 Feb 2006, Daniel Eiband wrote:

> I hope this mailing list is suitable, because it might be that my probem is
> due to a libtool bug.
>
> I try to cross-compile libgcrypt for a mipsel host in a buildroot like
> environment. It works fine, except on machines with a host version of
> libgpg-error installed in /usr/lib/ (libgpg-error was configured with
> --prefix=/usr, but installed into the
> $(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib).
>
> My configure looks like this:
>
> PATH=$(TARGET_TOOLCHAIN_PATH) \
> CFLAGS="$(TARGET_CFLAGS)" \
> CPPFLAGS="-I$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/include" \
> LDFLAGS="-L$(TARGET_TOOLCHAIN_STAGING_DIR)/lib
> -L$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib" \
> ./configure \
> --target=$(GNU_TARGET_NAME) \
> --host=$(GNU_TARGET_NAME) \
> --build=$(GNU_HOST_NAME) \
> --program-prefix="" \
> --program-suffix="" \
> --prefix=/usr \
> --sysconfdir=/etc \
> --disable-nls \
> --disable-largefile \
> --enable-shared \
> --enable-static \
> --disable-rpath \
> --disable-asm \
> --with-gpg-error-prefix="$(TARGET_TOOLCHAIN_STAGING_DIR)/usr"

I had an equal problem. The --with-gpg-error-prefix seems not to work as
expected. I used following method after looking in the configure file
(assuming libgpg-error is a subdirectory in current dir):

export GPG_ERROR_CONFIG=`pwd`/libgpg-error/src/gpg-error-config
export CPPFLAGS=-I`pwd`
export LDFLAGS=-L`pwd`
ln -sf libgpg-error/src/.libs/libgpg-error.a .
ln -sf libgpg-error/src/gpg-error.h .

In current dir (`pwd`) now are the links to the .a file and the .h file of
gpg-error, thats why the include paths point to this.

./configure --with-gpg-error-prefix=dummy ...

...

export -n GPG_ERROR_CONFIG
export -n CPPFLAGS
export -n LDFLAGS

I hope I stripped the relevant parts from my script, so you can follow
the idea.

Ciao
--
http://www.dstoecker.de/ (PGP key available)

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: cross-compiling to mipsel [ In reply to ]
Am Donnerstag 23 Februar 2006 18:08 schrieben Sie:
> I had an equal problem. The --with-gpg-error-prefix seems not to work as
> expected. I used following method after looking in the configure file
> (assuming libgpg-error is a subdirectory in current dir):
>
> export GPG_ERROR_CONFIG=`pwd`/libgpg-error/src/gpg-error-config
> export CPPFLAGS=-I`pwd`
> export LDFLAGS=-L`pwd`
> ln -sf libgpg-error/src/.libs/libgpg-error.a .
> ln -sf libgpg-error/src/gpg-error.h .
>
> In current dir (`pwd`) now are the links to the .a file and the .h file of
> gpg-error, thats why the include paths point to this.
>
> ./configure --with-gpg-error-prefix=dummy ...

--with-gpg-error-prefix is the prefix where you installed gpg-error. It seams
like you didn't install it at all. Besides, this is not my problem.
Nevertheless, thanks for your reply.

Regards,
Daniel

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: cross-compiling to mipsel [ In reply to ]
On Thu, 23 Feb 2006, Daniel Eiband wrote:

> Am Donnerstag 23 Februar 2006 18:08 schrieben Sie:
> > I had an equal problem. The --with-gpg-error-prefix seems not to work as
> > expected. I used following method after looking in the configure file
> > (assuming libgpg-error is a subdirectory in current dir):
> >
> > export GPG_ERROR_CONFIG=`pwd`/libgpg-error/src/gpg-error-config
> > export CPPFLAGS=-I`pwd`
> > export LDFLAGS=-L`pwd`
> > ln -sf libgpg-error/src/.libs/libgpg-error.a .
> > ln -sf libgpg-error/src/gpg-error.h .
> >
> > In current dir (`pwd`) now are the links to the .a file and the .h file of
> > gpg-error, thats why the include paths point to this.
> >
> > ./configure --with-gpg-error-prefix=dummy ...
>
> --with-gpg-error-prefix is the prefix where you installed gpg-error. It seams

It probably should be, but it is not. Read the autogenerated ./configure
file to understand why I use the environment variable and set
--with-gpg-error-prefix to dummy. It took me some time to understand, why
--with-gpg-error-prefix did not work as expected and how to work around.

> like you didn't install it at all. Besides, this is not my problem.

Excactly. I did not INSTALL it, but compiled a local copy of gpg-error.
This is usually what you need for cross compiling also (at least in static
mode). In dynamic mode you need to do some path magic to get it to work on
you destination system as well.

Ciao
--
http://www.dstoecker.de/ (PGP key available)

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: cross-compiling to mipsel [ In reply to ]
Am Freitag, 24. Februar 2006 09:09 schrieb Dirk Stoecker:
> On Thu, 23 Feb 2006, Daniel Eiband wrote:
> > Am Donnerstag 23 Februar 2006 18:08 schrieben Sie:
> > > export GPG_ERROR_CONFIG=`pwd`/libgpg-error/src/gpg-error-config
> > > export CPPFLAGS=-I`pwd`
> > > export LDFLAGS=-L`pwd`
> > > ln -sf libgpg-error/src/.libs/libgpg-error.a .
> > > ln -sf libgpg-error/src/gpg-error.h .
> > >
> > > In current dir (`pwd`) now are the links to the .a file and the .h file
> > > of gpg-error, thats why the include paths point to this.
> > >
> > > ./configure --with-gpg-error-prefix=dummy ...
> >
> > --with-gpg-error-prefix is the prefix where you installed gpg-error. It
> > seams
>
> It probably should be, but it is not. Read the autogenerated ./configure
> file to understand why I use the environment variable and set
> --with-gpg-error-prefix to dummy. It took me some time to understand, why
> --with-gpg-error-prefix did not work as expected and how to work around.

I think it works as expected. You are lucky that you only have one header in
this case. Otherwise these symlinks would be really annoying.

> > like you didn't install it at all. Besides, this is not my problem.
>
> Excactly. I did not INSTALL it, but compiled a local copy of gpg-error.
> This is usually what you need for cross compiling also (at least in static
> mode). In dynamic mode you need to do some path magic to get it to work on
> you destination system as well.

That's why I compile it with the prefix /usr and install it with the prefix
$(STAGING_DIR)/usr. Why working around and fixing some behaviour
which ./configure is not supposed to do? make install does it for you, just
use another prefix while installing.

Back to my original problem:

If i insert "|| true" here in the libtool

done
if test "$found" != yes || true; then
# deplib doesn't seem to be a libtool library

it works just fine, because then -lgpg-error is not substituted
by /usr/lib/gpg-error.so.

There is another patch from the OpenWRT buildroot necessary to compile the
tests:

diff -ruN libgcrypt-1.2.1-orig/tests/Makefile.am
libgcrypt-1.2.1-1/tests/Makefile.am
--- libgcrypt-1.2.1-orig/tests/Makefile.am 2004-03-03 09:08:05.000000000 +0100
+++ libgcrypt-1.2.1-1/tests/Makefile.am 2005-03-15 21:36:49.000000000 +0100
@@ -21,7 +21,7 @@
TESTS = prime register ac basic tsexp keygen pubkey benchmark

INCLUDES = -I$(top_srcdir)/src
-LDADD = ../src/libgcrypt.la
+LDADD = ../src/libgcrypt.la @LTLIBOBJS@ @GPG_ERROR_LIBS@

EXTRA_PROGRAMS = testapi
noinst_PROGRAMS = $(TESTS)
diff -ruN libgcrypt-1.2.1-orig/tests/Makefile.in
libgcrypt-1.2.1-1/tests/Makefile.in
--- libgcrypt-1.2.1-orig/tests/Makefile.in 2005-01-05 14:53:23.000000000 +0100
+++ libgcrypt-1.2.1-1/tests/Makefile.in 2005-03-15 21:37:12.000000000 +0100
@@ -258,7 +258,7 @@
target_vendor = @target_vendor@
TESTS = prime register ac basic tsexp keygen pubkey benchmark
INCLUDES = -I$(top_srcdir)/src
-LDADD = ../src/libgcrypt.la
+LDADD = ../src/libgcrypt.la @LTLIBOBJS@ @GPG_ERROR_LIBS@
AM_CFLAGS = @GPG_ERROR_CFLAGS@
all: all-am


Regards,
Daniel

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel