Hello,
I encountered some issues when building NTL along with a non-system GMP, but with GMP installed on the system. There are 2 problems related :
A. setup3 rule does not propagate $(GMP_OPT_LIB) to binary
setup3:
$(LINK) $(GMP_OPT_INCDIR) -o gen_gmp_aux gen_gmp_aux.cpp $(GMP_OPT_LIBDIR) $(GMP_OPT_LIB) $(LDLIBS)
./gen_gmp_aux > ../include/NTL/gmp_aux.h
The -L<path to gmp /lib> is given to the linker, but the next line executing the program will not be aware (when linking to dynamic gmp). This leads to the common issue :
GMP version check (6.2.1/6.0.0)
*** version number mismatch: inconsistency between gmp.h and libgmp
This can be mitigated with
- The
LD_LIBRARY_PATH is set with the same gmp folder, as advised in other issues relating the problem
$(GMP_OPT_LIB) actually also encodes an rpath
Point one is not always possible, e.g., when installing GMP and NTL in a prefix along with a new libreadline setup. Using LD_LIBRARY_PATH would most likely have your bash segfault.
Point 2 is the solution used by package managers like nix or spack, to avoid the segfault issue described above.
B. The configure script does not read LDFLAGS from the environment
My workaround is to use LDFLAGS with rpath, so that it does not affect by current $SHELL. However the configure script does not read LDFLAGS from the environment, and I had to explicitly pass it to the script :
export LDFLAGS="XXX"
./configure # ignores LDFLAGS
./configure LDFLAGS="XXX" # properly sets ld flags
Had few hours trying to figure this out ^^'
The point A seems kinda tricky to address to me, not sure if there is a best practice. The c++ code states that this is inspired from MPFR :
|
// check that vesrion numbers match as a consistency check |
|
// This is adapted from MPFR's configure script |
|
bool bad_version = false; |
|
sprintf(buffer, "%d.%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, |
|
__GNU_MP_VERSION_PATCHLEVEL); |
|
fprintf(stderr, "GMP version check (%s/%s)\n", buffer, gmp_version); |
|
if (strcmp(buffer, gmp_version)) { |
|
if (__GNU_MP_VERSION_PATCHLEVEL != 0) |
|
bad_version = true; |
|
else { |
|
sprintf(buffer, "%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR); |
|
if (strcmp(buffer, gmp_version)) bad_version = true; |
|
} |
|
} |
I did not, however, enounter any similar issue when building MPFR. Maybe they have a new way for checking this ?
On the other hand, I believe having the configure script reading the LDFLAGS from the environnement is reasonable... although I just give a workaround here :)
Best.
Hello,
I encountered some issues when building NTL along with a non-system GMP, but with GMP installed on the system. There are 2 problems related :
A. setup3 rule does not propagate
$(GMP_OPT_LIB)to binaryThe
-L<path to gmp /lib>is given to the linker, but the next line executing the program will not be aware (when linking to dynamic gmp). This leads to the common issue :This can be mitigated with
LD_LIBRARY_PATHis set with the same gmp folder, as advised in other issues relating the problem$(GMP_OPT_LIB)actually also encodes an rpathPoint one is not always possible, e.g., when installing GMP and NTL in a prefix along with a new libreadline setup. Using LD_LIBRARY_PATH would most likely have your bash segfault.
Point 2 is the solution used by package managers like nix or spack, to avoid the segfault issue described above.
B. The configure script does not read LDFLAGS from the environment
My workaround is to use LDFLAGS with rpath, so that it does not affect by current $SHELL. However the configure script does not read LDFLAGS from the environment, and I had to explicitly pass it to the script :
Had few hours trying to figure this out ^^'
The point A seems kinda tricky to address to me, not sure if there is a best practice. The c++ code states that this is inspired from MPFR :
ntl/src/gen_gmp_aux.cpp
Lines 113 to 126 in 91acd5b
I did not, however, enounter any similar issue when building MPFR. Maybe they have a new way for checking this ?
On the other hand, I believe having the configure script reading the LDFLAGS from the environnement is reasonable... although I just give a workaround here :)
Best.