Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building from source on Rocky 8.10 eigen3 library not found #3485

Open
trevorkarn opened this issue Sep 18, 2024 · 16 comments
Open

Building from source on Rocky 8.10 eigen3 library not found #3485

trevorkarn opened this issue Sep 18, 2024 · 16 comments
Labels
build issue platform specific issues involving compiling M2, generating examples, or running tests

Comments

@trevorkarn
Copy link

trevorkarn commented Sep 18, 2024

I am trying to install from source on a Rocky 8.10 system which I don't have admin access on.

I tried following the directions at https://macaulay2.com/Downloads/SourceCode/, cloned from GitHub into ~/M2/ and ran

cd ${HOME}/M2/M2
make 
mkdir ${HOME}/M2/M2/BUILD/foo
cd ${HOME}/M2/M2/BUILD/foo
../../configure --prefix=${HOME}/local CPPFLAGS="-I/${HOME}/local/include" LIBS="-L/${HOME}/local/lib64/"

I initially had issues with tbb, but followed #3055, and installed the newest version of tbb using cmake following https://github.com/oneapi-src/oneTBB/blob/master/INSTALL.md. I did use -DCMAKE_INSTALL_PREFIX=${HOME}/local since I don't have admin access. That solved the tbb problem.

After solving the tbb problem, I again ran

../../configure --prefix=${HOME}/local CPPFLAGS="-I/${HOME}/local/include" LIBS="-L/${HOME}/local/lib64/"

from M2/BUILD/foo. Then I got the error

checking whether eigen3 library is installed... configure: error: eigen library not found

and the build stopped. I tried building the eigen3 library but that did not work for some reason. I think that eigen3 did install, because I am able to run the toy program from https://eigen.tuxfamily.org/dox/GettingStarted.html that prints a matrix by running

% g++ -I ${HOME}/local/include/eigen3 my_program.cpp -o my_program
% ./my_program 
  3  -1
2.5 1.5

I would have thought that setting CPPFLAGS="-I/${HOME}/local/include" would have been enough to fix the problem, but I am wrong.

@mahrud mahrud added the build issue platform specific issues involving compiling M2, generating examples, or running tests label Sep 18, 2024
@d-torrance
Copy link
Member

Does CPPFLAGS="-I/${HOME}/local/include/eigen3 help?

@mahrud
Copy link
Member

mahrud commented Sep 18, 2024

@d-torrance should autotools build also have a target to download/configure/install eigen? (it's a header-only library so there's nothing to build really)

@trevorkarn
Copy link
Author

I ended up doing

 export PKG_CONFIG_PATH=${HOME}/local/share/pkgconfig/
 export LD_LIBRARY_PATH=${HOME}/local/lib64

and running

 ../../configure --prefix=${HOME}/local CPPFLAGS="-I/${HOME}/local/include" LDFLAGS="-L/${HOME}/local/lib64/ -L/${HOME}/local/lib" --without-libffi --enable-download

I then ran make and that seems to be working, but the build has not completely finished yet.

@d-torrance
Copy link
Member

should autotools build also have a target to download/configure/install eigen?

Yeah, that's a good idea.

@mahrud
Copy link
Member

mahrud commented Sep 19, 2024

@trevorkarn did the build succeed? I added a reference to this issue in the wiki. Feel free to add any other details that would be helpful for people building M2 on RHEL in the future.

@trevorkarn
Copy link
Author

It did not succeed. I am now struggling with GIVARO

@d-torrance
Copy link
Member

For what it's worth, once #3487 is merged, eigen should be discovered without having to mess with pkg-config, so long as it's installed in a standard header directory or CPPFLAGS is set correctly. And if it's not found, then it will be installed automatically in the build directory. (It's also possible to avoid this entirely on RHEL by installing the eigen3 package from EPEL.)

What specific givaro issues are you having? I've also been trying to get the build to work in RHEL 8, ideally before the next release, but there are lots of little issues like this since so few packages are available in the RHEL repositories.

@trevorkarn
Copy link
Author

trevorkarn commented Sep 19, 2024

I installed givaro, by following https://github.com/linbox-team/givaro?tab=readme-ov-file#download-and-install with

./autogen.sh --prefix=${HOME}/givaro

I am again having trouble configuring. I tried

export PKG_CONFIG_PATH=${HOME}/local/share/pkgconfig/:${HOME}/local/lib64/pkgconfig/:${HOME}/givaro/lib/pkgconfig
export LD_LIBRARY_PATH=${HOME}/local/lib64
export GIVARO_LIBS=${HOME}/givaro/include
../../configure --prefix=${HOME}/local CPPFLAGS="-I/${HOME}/local/include" LDFLAGS="-L/${HOME}/local/lib64/ -L/${HOME}/local/lib" --without-libffi --enable-download

and get the error

checking whether getaddrinfo can handle numeric service (port) numbers... configure: error: test file failed to compile

If I ignore that error, and run make anyway, since I think a previous configuration seemed to work (how do I check that?), I get

...
## --------------------------------------- ##
##        START FFLAS-FFPACK CONFIG        ##
## --------------------------------------- ##
checking for family name of compiler... checking whether g++ supports C++11 features by default... yes
---------------------------------------
checking whether to enable debugging options in the library... no
checking whether to enable profiling everything in the library... no
checking whether to enable warnings when compiling the library... no
checking whether C++ compiler accepts -march=native... yes
configure: "Adding '-march=native' to OPTIM_FLAGS"
---------------------------------------
checking size of char... 1
checking size of short... 2
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of __int64_t... 8
checking for __int128_t... yes
checking whether byte ordering is bigendian... no
---------------------------------------
checking for OpenMP... no
Default path = /usr /usr/local
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GIVARO... yes
checking for GIVARO usability... no
configure: error: The Givaro library could not be used with the compiler and the flags set up by the configure script
make: *** [GNUmakefile:211: submodules/fflas_ffpack/Makefile] Error 1

@trevorkarn
Copy link
Author

I reinstalled givaro in ~/local using ./autogen.sh --prefix=${HOME}/local instead of what I did above. Then things get further:

% cd ~/M2/M2/BUILD/foo
% export PKG_CONFIG_PATH=${HOME}/local/share/pkgconfig/:${HOME}/local/lib64/pkgconfig/:${HOME}/local/lib/pkgconfig/
% make

which gives output ending in

## --------------------------------------- ##
##        START FFLAS-FFPACK CONFIG        ##
## --------------------------------------- ##
checking for family name of compiler... checking whether g++ supports C++11 features by default... yes
---------------------------------------
checking whether to enable debugging options in the library... no
checking whether to enable profiling everything in the library... no
checking whether to enable warnings when compiling the library... no
checking whether C++ compiler accepts -march=native... yes
configure: "Adding '-march=native' to OPTIM_FLAGS"
---------------------------------------
checking size of char... 1
checking size of short... 2
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of __int64_t... 8
checking for __int128_t... yes
checking whether byte ordering is bigendian... no
---------------------------------------
checking for OpenMP... no
Default path = /usr /usr/local
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GIVARO... yes
checking for GIVARO usability... yes
---------------------------------------
checking for use of MKL... no 
checking for BLAS... problem
*******************************************************************************
 ERROR: BLAS not found!
 BLAS routines are required for this library to compile. Please
 make sure BLAS are installed and specify its location with the option
 --with-blas-libs=<libs> and if necessary --with-blas-cflags=<cflags>
 when running configure.
*******************************************************************************
make: *** [GNUmakefile:211: submodules/fflas_ffpack/Makefile] Error 1
make: Leaving directory '/users/0/karnx018/M2/M2/BUILD/foo'

@d-torrance
Copy link
Member

You shouldn't have to build givaro yourself -- the M2 build script will do it for you.

That being said, I'm getting stuck at the same spot you are. The BLAS part of the autotools build needs an overhaul -- I'm hoping to work on that soon.

@trevorkarn
Copy link
Author

How do I tell which things I should have to build myself and which things the M2 build script will/is supposed to do for me?

I didn't have BLAS installed, so I am trying to install BLAS from source now.

@d-torrance
Copy link
Member

Basically, if you get an error before configure finishes (like the one you were getting with eigen), then the M2 build script expects it to be installed already. If configure finishes without an error, then it will build everything that it needs. You can see the list of things it will build by looking for this output towards the end:

configure: using BUILDLIST     =  gc gmp mpfi normaliz ntl flint factory lapack mpsolve frobby glpk cddlib givaro fflas_ffpack gtest memtailor mathic mathicgb eigen 4ti2 gfan csdp nauty lrslib gftables topcom cohomcalg msolve

If you build BLAS manually, then you might be able to point fflas-ffpack in the right direction by modifying M2/libraries/fflas_ffpack/Makefile.in and adding CONFIGOPTIONS += --with-blas-libs=... --with-blas-cflags=....

@mikestillman
Copy link
Member

I'd also like to try building on autotools and cmake on macos sonoma, with all packages being built. So far, I have had some troubles also with at least eigen (if I recall correctly). It would be nice to make sure this works.

@trevorkarn
Copy link
Author

trevorkarn commented Sep 19, 2024

I sucessfully built OpenBLAS using

cd ${HOME}
git clone https://github.com/OpenMathLib/OpenBLAS.git
cd OpenBLAS
make
make install PREFIX=${HOME}/local

I modified M2/libraries/fflas_ffpack/Makefile.in, adding a new line

CONFIGOPTIONS += --with-blas-libs="${HOME}/local/lib" --with-blas-cflags="${HOME}/local/include"

It failed with:

....
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:196: undefined reference to `cblas_dtrmm'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:193: undefined reference to `openblas_set_num_threads'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:196: undefined reference to `cblas_dtrmm'
../e/dmat.o: In function `Givaro::Modular<double, double, void>::Element_ptr FFPACK::Invert2<Givaro::Modular<double, double, void> >(Givaro::Modular<double, double, 
void> const&, unsigned long, Givaro::Modular<double, double, void>::Element_ptr, unsigned long, Givaro::Modular<double, double, void>::Element_ptr, unsigned long, in
t&)':
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_fassign.inl:120: undefined reference to `openblas_set_num_threads'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_fassign.inl:122: undefined reference to `cblas_dcopy'
collect2: error: ld returned 1 exit status
real    1m49.602s
user    0m8.204s
sys     0m4.090s
make[2]: *** [Makefile:133: /users/0/karnx018/M2/M2/BUILD/foo/usr-dist/x86_64-Linux-Rocky-8.10/bin/M2-binary] Error 1
make[2]: Leaving directory '/users/0/karnx018/M2/M2/BUILD/foo/Macaulay2/bin'
make[1]: *** [Makefile:15: all-in-bin] Error 2
make[1]: Leaving directory '/users/0/karnx018/M2/M2/BUILD/foo/Macaulay2'
make: *** [GNUmakefile:251: all-in-Macaulay2] Error 2
make: Leaving directory '/users/0/karnx018/M2/M2/BUILD/foo'

Do you have any advice of where to go from here?

@d-torrance
Copy link
Member

To tell the linker where libraries are, you'll want to use "-L" and to tell the compiler where headers are, you'll want to use "-I". So it will probably be something like:

CONFIGOPTIONS += --with-blas-libs="-L${HOME}/local/lib" --with-blas-cflags="-I${HOME}/local/include"

You may also need -lcblas, -lopenblas, or similar in --with-blas-libs. Flags that look like -lfoo tell the linker to look for a file named libfoo.so, so see what .so files OpenBLAS installed in ~/local/lib and play around with those.

@trevorkarn
Copy link
Author

trevorkarn commented Sep 19, 2024

I have the following .so files in ~/local/lib:

% ls ~/local/lib | grep ".so"
libeigen_blas.so
libeigen_lapack.so
libgivaro.so
libgivaro.so.9
libgivaro.so.9.2.1
libopenblas.so
libopenblas.so.0
libopenblas_zenp-r0.3.28.dev.so

so I adjusted the fflas_ffpack/Makefile.in to have the line

CONFIGOPTIONS += --with-blas-libs="-L${HOME}/local/lib -lopenblas -lgivaro -leigen_blas" --with-blas-cflags="-I${HOME}/local/include"

and I continue to get

/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:193: undefined reference to `openblas_set_num_threads'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:196: undefined reference to `cblas_dtrmm'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:193: undefined reference to `openblas_set_num_threads'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:196: undefined reference to `cblas_dtrmm'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:193: undefined reference to `openblas_set_num_threads'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:196: undefined reference to `cblas_dtrmm'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:193: undefined reference to `openblas_set_num_threads'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_ftrmm_src.inl:196: undefined reference to `cblas_dtrmm'
../e/dmat.o: In function `Givaro::Modular<double, double, void>::Element_ptr FFPACK::Invert2<Givaro::Modular<double, double, void> >(Givaro::Modular<double, double, 
void> const&, unsigned long, Givaro::Modular<double, double, void>::Element_ptr, unsigned long, Givaro::Modular<double, double, void>::Element_ptr, unsigned long, in
t&)':
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_fassign.inl:120: undefined reference to `openblas_set_num_threads'
/users/0/karnx018/M2/M2/BUILD/foo/usr-host/include/fflas-ffpack/fflas/fflas_fassign.inl:122: undefined reference to `cblas_dcopy'
collect2: error: ld returned 1 exit status
real    0m14.111s
user    0m7.593s
sys     0m2.849s
make[2]: *** [Makefile:133: /users/0/karnx018/M2/M2/BUILD/foo/usr-dist/x86_64-Linux-Rocky-8.10/bin/M2-binary] Error 1
make[2]: Leaving directory '/users/0/karnx018/M2/M2/BUILD/foo/Macaulay2/bin'
make[1]: *** [Makefile:15: all-in-bin] Error 2
make[1]: Leaving directory '/users/0/karnx018/M2/M2/BUILD/foo/Macaulay2'
make: *** [GNUmakefile:251: all-in-Macaulay2] Error 2
make: Leaving directory '/users/0/karnx018/M2/M2/BUILD/foo'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build issue platform specific issues involving compiling M2, generating examples, or running tests
Projects
None yet
Development

No branches or pull requests

4 participants