Possible gmp-4.2.2 link-time bug

Vincent Lefevre vincent at vinc17.org
Fri Nov 30 10:21:43 CET 2007


On 2007-11-30 09:49:46 +0100, Paul Zimmermann wrote:
> It also seems you miss -I/usr/local/include in your compilation line.

No need to use that. /usr/local/include is in the default search list
of gcc, as a system directory:

vin:~> cpp -v < /dev/null
[...]
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.2.3/include
 /usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"

vin:~> cpp -v -I/usr/local/include < /dev/null
[...]
ignoring duplicate directory "/usr/local/include"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.2.3/include
 /usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"

It may even be a bad idea to use it in a "-I" switch since it will be
ignored. For instance, with

  C_INCLUDE_PATH=/home/vlefevre/i686/include:/home/vlefevre/include

I get:

vin:~> cpp -v -I. -I/usr/local/include < /dev/null
[...]
ignoring duplicate directory "/usr/local/include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 .
 /home/vlefevre/i686/include
 /home/vlefevre/include
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.2.3/include
 /usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"

Note that contrary to ".", /usr/local/include is still after
the directories listed in C_INCLUDE_PATH (because it is in
the system-directory list).

This also means that if I have a GMP installed in my home directory
and a GMP installed in /usr/local and want to build some software
with the latter one by using -I/usr/local/include -L/usr/local/lib,
the wrong gmp.h will be chosen.

In short, it's much better to use C_INCLUDE_PATH. For instance:

vin:~> C_INCLUDE_PATH=/usr/local/include:/home/vlefevre/i686/include:/home/vlefevre/include cpp -v -I. < /dev/null
[...]
#include "..." search starts here:
#include <...> search starts here:
 .
 /usr/local/include
 /home/vlefevre/i686/include
 /home/vlefevre/include
 /usr/lib/gcc/i486-linux-gnu/4.2.3/include
 /usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"

Here /usr/local/include is at the right place.

-- 
Vincent Lefèvre <vincent at vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


More information about the gmp-bugs mailing list