[Top][All Lists]

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

Linking with '-L /path/to/lib' (note the space!)

From: Olaf Lenz
Subject: Linking with '-L /path/to/lib' (note the space!)
Date: Thu, 21 Aug 2008 14:56:10 +0200
User-agent: Thunderbird (X11/20080724)

Hash: SHA1


I believe I have found what I would call a usability problem in libtool.
It is not exactly a bug, but leads to highly confusing behavior.

I could reproduce the problem with libtool 1.5.26 and 2.2 on Ubuntu 8.04.

Quick description:
- -------------------
When I pass the option "-L /path/to/lib" (note the space between -L and
/path/to/lib) to libtool in linking mode, libtool does not fail nor does
it give a warning, but instead the option will be interpreted as two
options, so that the linker command will get the current working
directory as flag to the linker (from -L), plus /path/to/lib as compiler
input argument.

The problem can easily occur in conjunction with autoconf/automake. As
gcc is able to handle the space,

        configure LDFLAGS="-L /path/to/lib"

it is readily processed, and configure will succeed. Compilation will
only fail as soon as libtool is used in the tool chain, and it will
produce a highly confusing error (file format not recognized).

Steps to reproduce:
- -------------------
Create a minimal c source file:
> cat > lttest.c
int main() {}

Compile the file using libtool:
> libtool --tag CC --mode=compile gcc lttest.c
libtool: compile:  gcc lttest.c  -fPIC -DPIC -o .libs/lttest.o
libtool: compile:  gcc lttest.c -o lttest.o >/dev/null 2>&1

Now link the file using libtool, giving an arbitrary additional lib path
(/opt in this case):
> libtool --tag CC --mode=link gcc lttest.c -L /opt -o lttest.out
libtool: link: gcc lttest.c /opt -o lttest.out  -L/home/olenz/tmp
/usr/bin/ld: /opt: No such file: File format not recognized
collect2: ld returned 1 exit status

Suggested solution:
- -------------------
I would suggest either to handle the space, which is probably not the
best solution, or to give a gentle warning when '-L' is used without any
further argument before the next space, because this is most probably
not what the user wanted.
The current behavior, where "-L" will be translated to "-L$HOME" is not

Best regards

        Olaf Lenz
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


reply via email to

[Prev in Thread] Current Thread [Next in Thread]