SeisSol / easi

A library for the Easy Initialization of model parameters.
https://easyinit.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
1 stars 6 forks source link

Installing SeisSol dependency easi error:undefined reference to H5free_memory #47

Closed Lipeng-Lai closed 2 weeks ago

Lipeng-Lai commented 9 months ago

"Error occurred when I executed the following command in the Compilation module."

cmake -DCMAKE_PREFIX_PATH=$HOME -DCMAKE_INSTALL_PREFIX=$HOME -DASAGI=ON -DIMPALAJIT=ON -DLUA=ON $EASI_SRC
make -j4 install
wc@VM-4-3-ubuntu:~/easi$ cmake -DCMAKE_PREFIX_PATH=$HOME -DCMAKE_INSTALL_PREFIX=$HOME -DASAGI=ON -DIMPALAJIT=ON -DLUA=ON $EASI_SRC
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.

-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/mpicc
-- Check for working C compiler: /usr/bin/mpicc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/mpiCC
-- Check for working CXX compiler: /usr/bin/mpiCC -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Found Lua: /home/wc/lib/liblua.a;/usr/lib/x86_64-linux-gnu/libm.so;dl (found version "5.3.6") 
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- Found HDF5: /home/wc/lib/libhdf5.a;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.10.8") found components: C HL 
-- Checking for module 'netcdf'
--   Found netcdf, version 4.6.1
-- Checking for module 'asagi'
--   Found asagi, version 1.0
-- Found MPI_C: /usr/bin/mpicc (found version "3.1") 
-- Found MPI_CXX: /usr/bin/mpiCC (found version "3.1") 
-- Found MPI: TRUE (found version "3.1")  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wc/easi
wc@VM-4-3-ubuntu:~/easi$ make -j4 install
Scanning dependencies of target easi
[  4%] Building CXX object CMakeFiles/easi.dir/src/component/AndersonianStress.cpp.o
[  8%] Building CXX object CMakeFiles/easi.dir/src/component/AffineMap.cpp.o
[ 12%] Building CXX object CMakeFiles/easi.dir/src/component/Composite.cpp.o
[ 16%] Building CXX object CMakeFiles/easi.dir/src/component/ConstantMap.cpp.o
[ 20%] Building CXX object CMakeFiles/easi.dir/src/component/DomainFilter.cpp.o
[ 24%] Building CXX object CMakeFiles/easi.dir/src/component/EvalModel.cpp.o
[ 28%] Building CXX object CMakeFiles/easi.dir/src/component/FunctionMap.cpp.o
[ 32%] Building CXX object CMakeFiles/easi.dir/src/component/LuaMap.cpp.o
[ 36%] Building CXX object CMakeFiles/easi.dir/src/component/LayeredModelBuilder.cpp.o
[ 40%] Building CXX object CMakeFiles/easi.dir/src/component/OptimalStress.cpp.o
[ 44%] Building CXX object CMakeFiles/easi.dir/src/component/PolynomialMap.cpp.o
[ 48%] Building CXX object CMakeFiles/easi.dir/src/component/SCECFile.cpp.o
[ 52%] Building CXX object CMakeFiles/easi.dir/src/component/Special.cpp.o
[ 56%] Building CXX object CMakeFiles/easi.dir/src/component/Switch.cpp.o
[ 60%] Building CXX object CMakeFiles/easi.dir/src/parser/YAMLComponentParsers.cpp.o
[ 64%] Building CXX object CMakeFiles/easi.dir/src/parser/YAMLHelpers.cpp.o
[ 68%] Building CXX object CMakeFiles/easi.dir/src/util/FunctionWrapper.cpp.o
[ 72%] Building CXX object CMakeFiles/easi.dir/src/util/RegularGrid.cpp.o
[ 76%] Building CXX object CMakeFiles/easi.dir/src/Query.cpp.o
[ 80%] Building CXX object CMakeFiles/easi.dir/src/YAMLParser.cpp.o
[ 84%] Building CXX object CMakeFiles/easi.dir/src/component/ASAGI.cpp.o
[ 88%] Building CXX object CMakeFiles/easi.dir/src/util/AsagiReader.cpp.o
[ 92%] Linking CXX static library libeasi.a
[ 92%] Built target easi
Scanning dependencies of target easicube
[ 96%] Building CXX object CMakeFiles/easicube.dir/tools/easicube.cpp.o
[100%] Linking CXX executable easicube
/usr/bin/ld: /home/wc/lib/libnetcdf.a(libnetcdf4_la-nc4file.o): in function `hdf5free':
nc4file.c:(.text+0x1f): undefined reference to `H5free_memory'
/usr/bin/ld: /home/wc/lib/libnetcdf.a(libnetcdf4_la-nc4file.o): in function `get_netcdf_type':
nc4file.c:(.text+0x7a): undefined reference to `H5Tget_class'
/usr/bin/ld: nc4file.c:(.text+0x9f): undefined reference to `H5Tis_variable_str'
/usr/bin/ld: nc4file.c:(.text+0xed): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0xf4): undefined reference to `H5T_NATIVE_SCHAR_g'
/usr/bin/ld: nc4file.c:(.text+0x106): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x138): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x13f): undefined reference to `H5T_NATIVE_SHORT_g'
/usr/bin/ld: nc4file.c:(.text+0x151): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x183): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x18a): undefined reference to `H5T_NATIVE_INT_g'
/usr/bin/ld: nc4file.c:(.text+0x19c): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x1ce): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x1d5): undefined reference to `H5T_NATIVE_FLOAT_g'
/usr/bin/ld: nc4file.c:(.text+0x1e7): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x219): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x220): undefined reference to `H5T_NATIVE_DOUBLE_g'
/usr/bin/ld: nc4file.c:(.text+0x232): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x264): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x26b): undefined reference to `H5T_NATIVE_UCHAR_g'
/usr/bin/ld: nc4file.c:(.text+0x27d): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x2af): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x2b6): undefined reference to `H5T_NATIVE_USHORT_g'
/usr/bin/ld: nc4file.c:(.text+0x2c8): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x2fa): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x301): undefined reference to `H5T_NATIVE_UINT_g'
/usr/bin/ld: nc4file.c:(.text+0x313): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x345): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x34c): undefined reference to `H5T_NATIVE_LLONG_g'
/usr/bin/ld: nc4file.c:(.text+0x35e): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x390): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x397): undefined reference to `H5T_NATIVE_ULLONG_g'
/usr/bin/ld: nc4file.c:(.text+0x3a9): undefined reference to `H5Tequal'
/usr/bin/ld: /home/wc/lib/libnetcdf.a(libnetcdf4_la-nc4file.o): in function `read_hdf5_a

The following are errors such as H5.... The error message is very long, so I intercepted part of it. How should I modify it?

sebwolf-de commented 9 months ago

Which version of HDF5 do you use? Did you intall it manually or is it a module/package? Is HDF5 compiled with the same compiler as easi (i.e. gcc 9.4.0)?

Lipeng-Lai commented 9 months ago

Which version of HDF5 do you use? Did you intall it manually or is it a module/package? Is HDF5 compiled with the same compiler as easi (i.e. gcc 9.4.0)?

I use hdf5-1.10.8,and manully install, I followed the instructions in https://seissol.readthedocs.io/en/latest/installing-dependencies.html to compile using mpicc,

InstallingHDF5
wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.8/src/hdf5-1.10.8.tar.bz2
tar -xaf hdf5-1.10.8.tar.bz2
cd hdf5-1.10.8
CPPFLAGS="-fPIC ${CPPFLAGS}" CC=mpicc FC=mpif90 ./configure --enable-parallel --prefix=$HOME --with-zlib --disable-shared --enable-fortran
make -j8
make install
cd..

. For easi, I also followed the tutorial configuration for the first time.

# $EASI_SRC is the directory into which you've cloned the easi source
cmake -DCMAKE_PREFIX_PATH=$HOME -DCMAKE_INSTALL_PREFIX=$HOME -DASAGI=ON -DIMPALAJIT=ON -DLUA=ON $EASI_SRC
make -j4 install

Later I saw your reply and I used

CC=mpicc FC=mpif90 cmake -DCMAKE_PREFIX_PATH=$HOME -DCMAKE_INSTALL_PREFIX=$HOME -DASAGI=ON -DIMPALAJIT=ON -DLUA=ON $EASI_SRC

make -j4 install

The error message is

wc@VM-4-3-ubuntu:~/easi$ make -j4 install
[92%] Built target ease
[96%] Linking CXX executable easicube
/usr/bin/ld: /home/wc/lib/libnetcdf.a(libnetcdf4_la-nc4file.o): in function `hdf5free':
nc4file.c:(.text+0x1f): undefined reference to `H5free_memory'
/usr/bin/ld: /home/wc/lib/libnetcdf.a(libnetcdf4_la-nc4file.o): in function `get_netcdf_type':
nc4file.c:(.text+0x7a): undefined reference to `H5Tget_class'
/usr/bin/ld: nc4file.c:(.text+0x9f): undefined reference to `H5Tis_variable_str'
/usr/bin/ld: nc4file.c:(.text+0xed): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0xf4): undefined reference to `H5T_NATIVE_SCHAR_g'
/usr/bin/ld: nc4file.c:(.text+0x106): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x138): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x13f): undefined reference to `H5T_NATIVE_SHORT_g'
/usr/bin/ld: nc4file.c:(.text+0x151): undefined reference to `H5Tequal'

Please can you tell me the reason? I am new to this, thank you

davschneller commented 9 months ago

Hi, what happens if you enter make VERBOSE=1?

Lipeng-Lai commented 9 months ago

Hi, what happens if you enter make VERBOSE=1?

ok, I enter make VERBOSE=1 in $HOME/easi, Now it looks like this

wc@VM-4-3-ubuntu:~/easi$ make VERBOSE=1
/usr/bin/cmake -S/home/wc/easi -B/home/wc/easi --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/wc/easi/CMakeFiles /home/wc/easi/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/wc/easi'
make -f CMakeFiles/easi.dir/build.make CMakeFiles/easi.dir/depend
make[2]: Entering directory '/home/wc/easi'
cd /home/wc/easi && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/wc/easi /home/wc/easi /home/wc/easi /home/wc/easi /home/wc/easi/CMakeFiles/easi.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/wc/easi'
make -f CMakeFiles/easi.dir/build.make CMakeFiles/easi.dir/build
make[2]: Entering directory '/home/wc/easi'
make[2]: Nothing to be done for 'CMakeFiles/easi.dir/build'.
make[2]: Leaving directory '/home/wc/easi'
[ 92%] Built target easi
make -f CMakeFiles/easicube.dir/build.make CMakeFiles/easicube.dir/depend
make[2]: Entering directory '/home/wc/easi'
cd /home/wc/easi && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/wc/easi /home/wc/easi /home/wc/easi /home/wc/easi /home/wc/easi/CMakeFiles/easicube.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/wc/easi'
make -f CMakeFiles/easicube.dir/build.make CMakeFiles/easicube.dir/build
make[2]: Entering directory '/home/wc/easi'
[ 96%] Linking CXX executable easicube
/usr/bin/cmake -E cmake_link_script CMakeFiles/easicube.dir/link.txt --verbose=1
/usr/bin/mpiCC     CMakeFiles/easicube.dir/tools/easicube.cpp.o  -o easicube  libeasi.a /home/wc/lib/libhdf5_hl.a /home/wc/lib/libhdf5.a /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libdl.so -lm /home/wc/lib/libasagi.a /usr/lib/x86_64-linux-gnu/libnuma.so /home/wc/lib/libnetcdf.a /home/wc/lib/libyaml-cpp.a /usr/lib/gcc/x86_64-linux-gnu/9/libgomp.so /home/wc/lib/libimpalajit.a /home/wc/lib/liblua.a -lm -ldl 
/usr/bin/ld: /home/wc/lib/libnetcdf.a(libnetcdf4_la-nc4file.o): in function `hdf5free':
nc4file.c:(.text+0x1f): undefined reference to `H5free_memory'
/usr/bin/ld: /home/wc/lib/libnetcdf.a(libnetcdf4_la-nc4file.o): in function `get_netcdf_type':
nc4file.c:(.text+0x7a): undefined reference to `H5Tget_class'
/usr/bin/ld: nc4file.c:(.text+0x9f): undefined reference to `H5Tis_variable_str'
/usr/bin/ld: nc4file.c:(.text+0xed): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0xf4): undefined reference to `H5T_NATIVE_SCHAR_g'
/usr/bin/ld: nc4file.c:(.text+0x106): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x138): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x13f): undefined reference to `H5T_NATIVE_SHORT_g'
/usr/bin/ld: nc4file.c:(.text+0x151): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x183): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x18a): undefined reference to `H5T_NATIVE_INT_g'
/usr/bin/ld: nc4file.c:(.text+0x19c): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x1ce): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x1d5): undefined reference to `H5T_NATIVE_FLOAT_g'
/usr/bin/ld: nc4file.c:(.text+0x1e7): undefined reference to `H5Tequal'
/usr/bin/ld: nc4file.c:(.text+0x219): undefined reference to `H5open'
/usr/bin/ld: nc4file.c:(.text+0x220): undefined reference to `H5T_NATIVE_DO
davschneller commented 9 months ago

Thanks; I have an idea where the problem could lie... That is, there may be something with the linking order in our CMake script.

If you go to https://github.com/SeisSol/easi/blob/7012d143a82ec92421509b43a5333dd51e348c0e/CMakeLists.txt#L198 (easi/CMakeLists.txt, line 198), and replace the line with

target_link_libraries(easicube PUBLIC PkgConfig::ASAGI PkgConfig::NETCDF ${HDF5_C_HL_LIBRARIES} ${HDF5_C_LIBRARIES})

Does it work then? The linking order of the static libraries needs to be changed, since Netcdf depends on Hdf5. ASAGI depends on the former both, so its placement is fine. (cf. also https://github.com/microsoft/onnxruntime/blob/main/docs/cmake_guideline.md#static-library-order-matters for the issue)

palgunadi1993 commented 7 months ago

Hi I got the same problem when installing on CSCS. The solution you provided is not working as well. However, after I turn off the ASAGI. It works. What could be another solution?

davschneller commented 7 months ago

If you just want to install SeisSol, then you can also set EASICUBE=OFF. That should avoid the above error. (easicube is a small helper program which is not ultimately needed for compiling SeisSol)

palgunadi1993 commented 7 months ago

Thanks. However, would this avoid the use of ASAGI?

davschneller commented 7 months ago

No, ASAGI can be included (i.e. ASAGI=ON, and EASICUBE=OFF). The error, at least as shown above, only affects a utility program.

palgunadi1993 commented 7 months ago

great, thanks.

davschneller commented 2 weeks ago

This problem may be fixed by #56 (and besides, it's generally avoided now by #55 ). There was another place where the Hdf5 libraries were linked before the Netcdf libraries, besides the one mentioned in this thread. Thus, the line mentioned here had no effect after all.

A local test showed that for the new master, Hdf5 is now included after Netcdf.

Closing for now—feel free to re-open or file a new issue if the problem should re-appear.