Project

General

Profile

Actions

Bug #2897

closed

Default compiler ignores LIBRARY_PATH

Added by enric almost 8 years ago. Updated almost 3 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
04/01/2016
Due date:
% Done:

0%

Estimated time:

Description

The default compiler of "DragonFly 4.4-RELEASE" ignores the value of the environment variable LIBRARY_PATH.

Steps to reproduce:

cat > foo.c
int foo(void) { return 42; }
^D

cat > main.c
int foo(void);
int main() { return foo(); }
^D

  1. commands to reproduce the problem:
    cc -c foo.c
    ar r libfoo.a foo.o
    LIBRARY_PATH=`pwd` cc main.c -lfoo
  1. observed behaviour: the compiler gives an error because it cannot find foo
  1. expected behaviour: the compiler produces a program a.out that returns 42
  1. workaround:
    cc main.c -lfoo -L`pwd`

This causes problems when compiling some packages that work correctly in other
systems, notably OpenBSD and Debian linux. This problem is easy to workaround
(once you identify it!). However, the behavior is inconsistent with the provided
documentation.

Quote from cc(1):

LIBRARY_PATH
The value of LIBRARY_PATH is a colon-separated list of directories,
much like PATH. When configured as a native compiler, GCC tries
the directories thus specified when searching for special linker
files, if it can't find them using GCC_EXEC_PREFIX. Linking using
GCC also uses these directories when searching for ordinary
libraries for the -l option (but directories specified with -L come
first).

Either the documentation or the compiler specs should be updated to be
consistent.

By running the compiler with the "-v" option, you can see that the variable is
acknowledged, however its values are not passed to the linker.

Actions

Also available in: Atom PDF