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 #1

Updated by dragonflybsd1 over 7 years ago

if anything, LD_LIBRARY_PATH would be used, but neither are good practice.

The resolution to this would be to remove mention of LIBRARY_PATH from cc(1) as suggested.

Actions #2

Updated by swildner almost 3 years ago

LD_LIBRARY_PATH is for the runtime linker, while LIBRARY_PATH is used at compile time.

So no, this looks like a valid bug.

See https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html too.

Actions #3

Updated by swildner almost 3 years ago

  • Status changed from New to Resolved
Actions

Also available in: Atom PDF