Problems with building with ADIOS2

This problem is not related to #45327, because it happens on other machine

I’m trying to build LAMMPS with ADIOS package

ADIOS build config Pastebin
LAMMPS build config Pastebin

When running cmake --build . the following error appears

[ 95%] Linking CXX executable lmp_serial
/usr/bin/ld: liblammps_serial.a(dump_atom_adios.cpp.o): in function `LAMMPS_NS::DumpAtomADIOS::openfile()':
/home/kein/repos/lammps/src/ADIOS/dump_atom_adios.cpp:91: undefined reference to `adios2::IO::Open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode, int)'
/usr/bin/ld: /home/kein/repos/lammps/src/ADIOS/dump_atom_adios.cpp:87: undefined reference to `adios2::IO::Open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode, int)'
/usr/bin/ld: liblammps_serial.a(dump_atom_adios.cpp.o): in function `LAMMPS_NS::DumpAtomADIOS::DumpAtomADIOS(LAMMPS_NS::LAMMPS*, int, char**)':
/home/kein/repos/lammps/src/ADIOS/dump_atom_adios.cpp:65: undefined reference to `adios2::ADIOS::ADIOS(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, bool)'
/usr/bin/ld: liblammps_serial.a(dump_custom_adios.cpp.o): in function `LAMMPS_NS::DumpCustomADIOS::openfile()':
/home/kein/repos/lammps/src/ADIOS/dump_custom_adios.cpp:103: undefined reference to `adios2::IO::Open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode, int)'
/usr/bin/ld: /home/kein/repos/lammps/src/ADIOS/dump_custom_adios.cpp:99: undefined reference to `adios2::IO::Open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode, int)'
/usr/bin/ld: liblammps_serial.a(dump_custom_adios.cpp.o): in function `LAMMPS_NS::DumpCustomADIOS::DumpCustomADIOS(LAMMPS_NS::LAMMPS*, int, char**)':
/home/kein/repos/lammps/src/ADIOS/dump_custom_adios.cpp:73: undefined reference to `adios2::ADIOS::ADIOS(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, bool)'
/usr/bin/ld: liblammps_serial.a(reader_adios.cpp.o): in function `LAMMPS_NS::ReaderADIOS::open_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/kein/repos/lammps/src/ADIOS/reader_adios.cpp:137: undefined reference to `adios2::IO::Open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode, int)'
/usr/bin/ld: liblammps_serial.a(reader_adios.cpp.o): in function `LAMMPS_NS::ReaderADIOS::ReaderADIOS(LAMMPS_NS::LAMMPS*)':
/home/kein/repos/lammps/src/ADIOS/reader_adios.cpp:85: undefined reference to `adios2::ADIOS::ADIOS(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, bool)'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/lmp.dir/build.make:109: lmp_serial] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:208: CMakeFiles/lmp.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

OS: Linux Mint 21
Platform: Linux redox 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64
Cmake version 3.22.1
This happens when I trying to build LAMMPS from both cloned git branches - stable and release

I have not encountered this error and cannot reproduce it on Fedora 36.

You are compiling with a non-standard compiler (GCC 10.x).
What happens, if you use the “native” compiler (GCC 11.x)?

I will try to set up a Mint Linux 21 container or virtual machine to reproduce this. What did you do to obtain the GCC 10.x compiler?

I cannot reproduce the linker error, but when running the same settings I get an error about using an MPI function call before MPI is initialized.

After some more digging, I figured out the following:

  • when compiling LAMMPS without MPI, you also must use an ADIOS library that has been configured with MPI disabled (via -DADIOS2_USE_MPI=off when configuring).
  • the ADIOS package needs to be modified to be compatible with such an ADIOS library since the API is different when MPI is not configured and the ADIOS package code in LAMMPS does not (yet) support it.
  • the changes to support a non-MPI ADIOS version are straightforward and will be included in the next patch release of LAMMPS.

Thus for now the conclusion is that this configuration is currently not supported. You must compile LAMMPS with MPI enabled if you want to use the ADIOS package.

Yes, understand.
Using MPI and GCC-11 everything compiles.