algebraic-solving / msolve

Library for Polynomial System Solving through Algebraic Methods
https://msolve.lip6.fr
GNU General Public License v2.0
90 stars 22 forks source link

Compilation problem #148

Closed rprebet closed 2 months ago

rprebet commented 3 months ago

I'm having troubles compiling msolve (I tried v0.6.5 and v0.6.6). When running the "make" command, I have the following error message:

/bin/bash ./libtool --tag=CC --mode=link gcc -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -maes -mavx -mfma -mavx2 -mrdrnd -mbmi -mbmi2 -madx -mabm -fopenmp -g -O2 -o msolve src/msolve/main.o src/neogb/libneogb.la src/fglm/libfglm.la src/usolve/libusolve.la -lflint -lmpfr -lgmp -lm libtool: link: gcc -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -maes -mavx -mfma -mavx2 -mrdrnd -mbmi -mbmi2 -madx -mabm -fopenmp -g -O2 -o .libs/msolve src/msolve/main.o src/neogb/.libs/libneogb.so src/fglm/.libs/libfglm.a src/usolve/.libs/libusolve.a -lflint -lmpfr -lgmp -lm -fopenmp /usr/bin/ld: src/fglm/.libs/libfglm.a(libfglm_la-fglm_core.o): in function nmod_mat_poly_mbasis': /home/remi/libs/msolve-0.6.6/src/fglm/../upolmat/nmod_mat_poly_mbasis.c:221: undefined reference tonmod_mat_permute_rows' /usr/bin/ld: src/fglm/.libs/libfglm.a(libfglm_la-fglm_core.o): in function nmod_poly_mat_truncate': /usr/local/include/flint/nmod_poly_mat.h:78: undefined reference tonmod_poly_mat_set_trunc' collect2: error: ld returned 1 exit status

NB: I use FLINT 3.1.2

vneiger commented 3 months ago

Thanks for reporting this. I'm not able to reproduce, with the same versions of msolve+flint. It seems that at linking stage gcc does not find some flint functions that were definitely there at v3.1.2 (they have been since v.3.0.0 at least). Could you please post line 78, and a few lines before and after it, of your /usr/local/include/flint/nmod_poly_mat.h ? Could you also give the list of files starting with libflint* in /usr/local/lib/ ? Thanks.

rprebet commented 3 months ago

Here it is:

/usr/local/include/flint/nmod_poly_mat.h - l.67-92: ########################################## void nmod_poly_mat_set(nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2);

void nmod_poly_mat_set_nmod_mat(nmod_poly_mat_t pmat, const nmod_mat_t cmat);

void nmod_poly_mat_clear(nmod_poly_mat_t mat);

/* Truncate, shift *****/

void nmod_poly_mat_set_trunc(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, long len);

NMOD_POLY_MAT_INLINE void nmod_poly_mat_truncate(nmod_poly_mat_t pmat, long len) { nmod_poly_mat_set_trunc(pmat, pmat, len); }

void nmod_poly_mat_shift_left(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k);

void nmod_poly_mat_shift_right(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k); #########################################

And in /usr/local/lib I have: libflint.so, libflint.so.18, libflint.so.18.0.1, libflint.so.19, libflint.so.19.0.0

vneiger commented 3 months ago

It may be that -lflint is not using the flint you would like to use. You have at least two versions but I suppose libflint.so points to libflint.so.19 (which is v3.1.2), so the culprit would rather be a third one installed somewhere else. Could you please compile the following program (say, test.c)

#include <flint/nmod.h>

int main()
{
    nmod_t mod;
    nmod_init(&mod, 17);
    return 0;
}

using gcc -o test.so test.c -shared -lflint, and let us know the output of ldd test.so ? Of particular interest is whether this contains a line like

╰─ ldd test.so
        [...]
        libflint.so.19 => /usr/local/lib/libflint.so.19 (0x00007bf9e0800000)
        [...]
rprebet commented 3 months ago

Here it is:

╰─ ldd test.so 
    linux-vdso.so.1 (0x00007ffc5137e000)
    libflint-2.8.4.so => /lib/x86_64-linux-gnu/libflint-2.8.4.so (0x00007d232b000000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007d232ac00000)
    libmpfr.so.6 => /usr/local/lib/libmpfr.so.6 (0x00007d232af51000)
    libgmp.so.10 => /usr/local/lib/libgmp.so.10 (0x00007d232b729000)
    libntl.so.44 => /lib/x86_64-linux-gnu/libntl.so.44 (0x00007d232a800000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007d232a400000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007d232ae6a000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007d232ae4a000)
    /lib64/ld-linux-x86-64.so.2 (0x00007d232b7ca000)
    libgf2x.so.3 => /lib/x86_64-linux-gnu/libgf2x.so.3 (0x00007d232b718000)

So this would be a problem in my flint installation?

vneiger commented 2 months ago

Ah, thanks for the ldd output, this is helpful. Your flint installation is not the problem as such, but you do have two versions installed, probably one via something like "apt install libflint-dev" and one from sources (e.g. the github repo). The ldd output indicates that if you use "-lflint" alone, the linker seeks the library in the system's "/lib" folder first, and that one is apparently flint 2.8.4. On the other hand as we saw above, during compilation msolve takes headers from /usr/local/include/flint/, and these are for 3.1.2. As expected, your system's 2.8.4 does not provide an implementation for some of the functions defined in the 3.1.2 headers.

Anyhow, the fix should simply be to indicate the right runtime library to make:

make LDFLAGS="-Wl,-rpath=/usr/local/lib -L/usr/local/lib"

Hope this works!

rprebet commented 2 months ago

It now works like a charm, thank you very much! I might try to fix these conflicting installations of flint though.