delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2013/12/21/06:18:22

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <52B57658.2070801@gmx.de>
Date: Sat, 21 Dec 2013 12:07:04 +0100
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: A question about gcc's LIBRARY_PATH and /dev/env/DJDIR
X-Provags-ID: V03:K0:MEzHquCfddYFPcJH1psmO1DNM+R1O2aHmn8flR5Q4dv9YRnQ8T9
o6L98srxNcdPzz+A3vTF76h/JkLGXrDhM09L74jDlmMhwM9prhPH1EUKDqTJO+QeRbxMi+R
KfnRruwMx2Z71IpIpu7vN93EiLNDYJ0Ietfxlcmkladj02CnDtc0EyUG/F7N4bpEIf0xlob
hep2ijAI+UmKxrsvCLqxA==
Reply-To: djgpp AT delorie DOT com

Please inspect to following code snippet:

#include <netdb.h>
int main(void)
{
   return 0;
}

I have tried to compile this using gcc482.  The code shall be linked with
libwatt.a using the following command:
   gcc -v a.c -lwatt
The code snippet is stored in the H:\l\_libxml2-2.9.1\_ directory (see later).

The watt-32 port is installed at its canonical place in the DJGPP installation
tree.  This is:
   /dev/env/DJDIR/net
In this directory all required watt-32 specific directories are created.
These are:
   /dev/env/DJDIR/net/watt/inc    for headers.
   /dev/env/DJDIR/net/watt/lib    for libraries.
Due to the fact that this port (intentionaly) does not install its headers
and its library in the DJGPP specific canonical places:
   /dev/env/DJDIR/include    for headers.
   /dev/env/DJDIR/lib        for libraries.
it is very important that the C_INCLUDE_PATH and LIBRARY_PATH environment
variables point to the watt-32 specific directories.  In my installation
this is:
   set C_INCLUDE_PATH=/dev/env/DJDIR/net/watt/inc
   set LIBRARY_PATH=/dev/env/DJDIR/net/watt/lib

Although the environment variables are set the linker fails to find the library.
To show what happens, I have compiled with gcc's -v option:

Using built-in specs.
COLLECT_GCC=C:\DJGPP-2.04\BIN/gcc.exe
COLLECT_LTO_WRAPPER=c:/djgpp-2.04/bin/../libexec/gcc/djgpp/4.82/lto-wrapper.exe
Target: djgpp
Configured with: /gnu/gcc-4.82/configure djgpp --disable-werror --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-libquadmath-support --disable-lto
Thread model: single
gcc version 4.8.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=pentium' '-march=pentium'
  c:/djgpp-2.04/bin/../libexec/gcc/djgpp/4.82/cc1.exe -quiet -v -iprefix c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/ -remap a.c -quiet -dumpbase a.c -mtune=pentium -march=pentium -auxbase a -version -o ./ccVihO4Q.s
GNU C (GCC) version 4.8.2 (djgpp)
     compiled by GNU C version 4.8.2, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory "c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/../../../../djgpp/include"
ignoring duplicate directory "c:/djgpp-2.04/lib/gcc/../../lib/gcc/djgpp/4.82/include"
ignoring duplicate directory "c:/djgpp-2.04/lib/gcc/../../lib/gcc/djgpp/4.82/include-fixed"
ignoring nonexistent directory "c:/djgpp-2.04/lib/gcc/../../lib/gcc/djgpp/4.82/../../../../djgpp/include"
#include "..." search starts here:
#include <...> search starts here:
  /dev/env/DJDIR/net/watt/inc
  c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/include
  c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/include-fixed
  c:/djgpp-2.04/include
End of search list.
GNU C (GCC) version 4.8.2 (djgpp)
     compiled by GNU C version 4.8.2, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: b64da8eb31f17f53c5a790655392b614
COLLECT_GCC_OPTIONS='-v' '-mtune=pentium' '-march=pentium'
  c:/djgpp-2.04/bin/as.exe -v -o ./ccDoJFsU.o ./ccVihO4Q.s
GNU assembler version 2.24 (djgpp) using BFD version (GNU Binutils) 2.24
COMPILER_PATH=c:/djgpp-2.04/bin/../libexec/gcc/djgpp/4.82/;c:/djgpp-2.04/bin/../libexec/gcc/;c:/djgpp-2.04/bin/
LIBRARY_PATH=c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/;c:/djgpp-2.04/bin/../lib/gcc/;c:/djgpp-2.04/lib/;c:/djgpp-2.04/lib/;c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/../../../
COLLECT_GCC_OPTIONS='-v' '-mtune=pentium' '-march=pentium'
  c:/djgpp-2.04/bin/../libexec/gcc/djgpp/4.82/collect2.exe c:/djgpp-2.04/lib/crt0.o -Lc:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82 -Lc:/djgpp-2.04/bin/../lib/gcc -Lc:/djgpp-2.04/lib -Lc:/djgpp-2.04/lib -Lc:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/../../.. ./ccDoJFsU.o -lwatt -lgcc -lc -lgcc
c:/djgpp-2.04/bin/ld.exe: cannot find -lwatt
collect2.exe: error: ld returned 1 exit status


As can be seen the C_INCLUDE_PATH environment variable is honored but the
LIBRARY_PATH is not honored at all.
Please inspected gcc's output for the -print-search-dirs option:

install: c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/
programs: =c:/djgpp-2.04/bin/../libexec/gcc/djgpp/4.82/;c:/djgpp-2.04/bin/../libexec/gcc/;c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/../../../../djgpp/bin/djgpp/4.82/;c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/../../../../djgpp/bin/;c:/djgpp-2.04/bin/djgpp/4.82/;c:/djgpp-2.04/bin/
libraries: =c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/;c:/djgpp-2.04/bin/../lib/gcc/;h:/net/watt/lib/djgpp/4.82/;h:/net/watt/lib/;c:/djgpp-2.04/lib/djgpp/4.82/;c:/djgpp-2.04/lib/;c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/../../../../djgpp/lib/djgpp/4.82/;c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/../../../../djgpp/lib/;c:/djgpp-2.04/lib/djgpp/4.82/;c:/djgpp-2.04/lib/;c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/../../../djgpp/4.82/;c:/djgpp-2.04/bin/../lib/gcc/djgpp/4.82/../../../

The thing that really confuses me are the following two library entries:
   h:/net/watt/lib/djgpp/4.82/
   h:/net/watt/lib/

The H: partition is the current working partition.
Instead of searching for the library at /dev/env/DJDIR/net/watt/lib
(aka c:/djgpp-2.04/net/watt/lib) gcc seems to replace the /dev/env/DJDIR prefix
by the current drive letter.  Please note that the drive letter used to create
the library path changes if I change the partition.  It seems to be that the
path is always constructed by replacing the /dev/env/DJDIR value by the current
drive letter.
Is there any reason why /dev/env/DJDIR seems to work for the include path
but fails for the library path?  Just for fun I tried a lot of other gcc
versions but they all fail to find the library.

Of course, if I replace /dev/env/DJDIR by c:/djgpp-2.04 in the LIBRARY_PATH
environment variable the compiler works flawlessly.  IMHO two questions arise:
  - why does the /dev/env/DJDIR prefix work for C_INCLUDE_PATH and fails for
    LIBRARY_PATH ?
  - why does gcc replace /dev/env/DJDIR by the current drive letter when
    creating the library paths?

I have read the gcc info doc and it tells that LIBRARY_PATH is a colon separated
list of directories to search for linker files if they cannot be found using
GCC_EXEC_PREFIX.  I have assumed that these directories are absolute paths and
not relative paths to the current partition or am I missing something?
Please note that all this is not an inconvenience to me but it is confusing
to have to remember which environment variable honors /dev/env/DJDIR and which
one does not.  Can /dev/env/DJDIR be used in an environment variable or not?

If more information is needed please contact me.


Regards,
Juan M. Guerrero

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019