[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fun with libtool and cross-builds

On 09/02/11 22:10, Simon Josefsson wrote:

Please try to debug where the -L/usr/lib comes from, I don't believe
libtool is adding this by itself but instead it is told to add it by
some incorrect .la file or similar.

This is from memory, as I also ran into the same problem. The problem is, if my memory serves me right, in the following scenario:
Cross build library A and install it with DESTDIR (obviously) to /tmp/otheroot
Try to cross build library B, that needs library A. Obviously, you're going to give it -L /tmp/otheroot/usr/lib. The problem is that the .la files in /tmp/otheroot/usr/lib point to /usr/lib as the place to find the library. This only becomes a problem when a native version of library A is installed on the real system, at which point the compiler prefers that version, and then fails as it is of the wrong architecture.

In my projects I wound up "fixing" the la file with sed as part of the build process, but that was an embedded project where:
  1. The la files were not installed to the destination machine, and
  2. The entire build was controlled by a single governing makefile.
If either one of these conditions is not present, my solution simply wouldn't work. Another solution is to build A with --prefix=/tmp/otheroot/usr, but I think we can all see how that might break stuff in the library if the destination path is used inside the code.

The only real solution I see for this is for libtool to have specific support for linking against DESTDIR installed libraries (maybe make it respect DESTDIR if it's defined during the build? That could be a solution that is both easy to understand and simple to integrate)

Shachar Shemesh
Lingnu Open Source Consulting Ltd.

Reply to: