New Intel icx and icpx compilers | use of undeclared identifier 'getenv'

GROMACS version: gromacs-2021.6, same error with 2024.2
GROMACS modification: No

I’m using the new intel C and C++ compilers as mpiicx and mpiicpx to compile gromacs, i.e.

> which mpiicx 
/path/programs/spack/opt/spack/linux-sles15-zen2/gcc-14.2.0/intel-oneapi-mpi-2021.13.1-uxkmsteetuh4j46e6x5muukdyr4snmb6/mpi/2021.13/bin/mpiicx

> which mpiicpx 
/path/programs/spack/opt/spack/linux-sles15-zen2/gcc-14.2.0/intel-oneapi-mpi-2021.13.1-uxkmsteetuh4j46e6x5muukdyr4snmb6/mpi/2021.13/bin/mpiicpx

But I’m getting this error:

modularsimulator/modularsimulator.h:131:15: error: use of undeclared identifier 'getenv'
  131 |            && getenv("GMX_DISABLE_MODULAR_SIMULATOR") == nullptr;
      |               ^
1 error generated.

Below is the tail output of VERBOSE=1 make:

[  6%] Building CXX object src/gromacs/modularsimulator/CMakeFiles/modularsimulator.dir/modularsimulator.cpp.o
cd /path/programs/mimic_sources_dev/gromacs-2021.6/build/src/gromacs/modularsimulator && /path/programs/spack/opt/spack/linux-sles15-zen2/gcc-14.2.0/intel-oneapi-compilers-2024.2.1-yh4w546foz4xqulspusmbashdmz4524h/compiler/2024.2/bin/icpx -DGMX_DOUBLE=1 -DHAVE_CONFIG_H -I/path/programs/mimic_sources_dev/gromacs-2021.6/build/src/external/build-fftw/fftwBuild-prefix/include -I/path/programs/mimic_sources_dev/gromacs-2021.6/build/src -I/path/programs/mimic_sources_dev/gromacs-2021.6/src -isystem /path/programs/mimic_sources_dev/gromacs-2021.6/src/external/thread_mpi/include -isystem /path/programs/spack/opt/spack/linux-sles15-zen2/gcc-14.2.0/intel-oneapi-mpi-2021.13.1-uxkmsteetuh4j46e6x5muukdyr4snmb6/mpi/2021.13/include -isystem /path/.local/include -isystem /path/programs/mimic_sources_dev/gromacs-2021.6/src/external --gcc-toolchain=/path/programs/spack/opt/spack/linux-sles15-zen2/gcc-12.3.0/gcc-14.2.0-lzugpkgeuobdiavasko3lpdknlwjqzib -O3 -DNDEBUG -std=c++17 -fPIC -fiopenmp -Wno-redundant-move -MD -MT src/gromacs/modularsimulator/CMakeFiles/modularsimulator.dir/modularsimulator.cpp.o -MF CMakeFiles/modularsimulator.dir/modularsimulator.cpp.o.d -o CMakeFiles/modularsimulator.dir/modularsimulator.cpp.o -c /path/programs/mimic_sources_dev/gromacs-2021.6/src/gromacs/modularsimulator/modularsimulator.cpp
In file included from /path/programs/mimic_sources_dev/gromacs-2021.6/src/gromacs/modularsimulator/modularsimulator.cpp:44:
/path/programs/mimic_sources_dev/gromacs-2021.6/src/gromacs/modularsimulator/modularsimulator.h:131:15: error: use of undeclared identifier 'getenv'
  131 |            && getenv("GMX_DISABLE_MODULAR_SIMULATOR") == nullptr;
      |               ^
1 error generated.
make[2]: *** [src/gromacs/modularsimulator/CMakeFiles/modularsimulator.dir/build.make:188: src/gromacs/modularsimulator/CMakeFiles/modularsimulator.dir/modularsimulator.cpp.o] Error 1
make[2]: Leaving directory '/path/programs/mimic_sources_dev/gromacs-2021.6/build'
make[1]: *** [CMakeFiles/Makefile2:5056: src/gromacs/modularsimulator/CMakeFiles/modularsimulator.dir/all] Error 2
make[1]: Leaving directory '/path/programs/mimic_sources_dev/gromacs-2021.6/build'
make: *** [Makefile:166: all] Error 2

I’m using:

module purge
source $WORK/programs/spack/share/spack/setup-env.sh
spack unload  --all
spack load gcc@14.2.0
spack load intel-oneapi-compilers@2024.2.1%gcc@14.2.0
spack load intel-oneapi-mkl@2024.2.1%gcc@14.2.0
spack load intel-oneapi-mpi@2021.13.1%gcc@14.2.0
spack load cmake@3.30.2%gcc@14.2.0
spack load git@2.45.2

And doing cmake like:

export INSTALL_DIR=${WORK}/.local
export PATH=${INSTALL_DIR}/bin:${PATH}

cmake -DCMAKE_BUILD_TYPE=Release -DGMX_DOUBLE=ON -DGMX_MPI=ON -DGMX_MIMIC=ON    -DGMX_BUILD_OWN_FFTW=ON   -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DCMAKE_PREFIX_PATH=${INSTALL_DIR} ..

Hi!

Could you double check that the error message is the same with GROMACS 2024.2?

For GROMACS 2021.6, you should add #include <cstdlib> to the top of the src/gromacs/modularsimulator/modularsimulator.h file (after the existing #include line there). But 2024.2 already has this fixed.

P.S.: the problem is likely due to GCC 14 (and its standard library), not ICPX 2024.2.

1 Like

Thanks a lot for your reply, @al42and

Do you perhaps mean to add
#include <cstdlib>
before (and not after) the existing
#include line?
For some reason, in the source code for gromacs 2024.2, I can read that is the case:

#include <cstdlib>
                                                                                                                                                                                                   
#include "gromacs/mdrun/isimulator.h"

So, I then added #include <cstdlib> before the existing #include line.

I get another error: The tail output of VERBOSE=1 make is:

[ 65%] Building CXX object src/gromacs/CMakeFiles/libgromacs.dir/analysisdata/dataframe.cpp.o
cd /path/programs/mimic_sources_dev/gromacs-2021.6/build/src/gromacs && /path/programs/spack/opt/spack/linux-sles15-zen2/gcc-14.2.0/intel-oneapi-compilers-2024.2.1-yh4w546foz4xqulspusmbashdmz4524h/compiler/2024.2/bin/icpx -DGMX_DOUBLE=1 -DHAVE_CONFIG_H -DUSE_STD_INTTYPES_H -Dlibgromacs_EXPORTS -I/path/programs/mimic_sources_dev/gromacs-2021.6/build/src/external/build-fftw/fftwBuild-prefix/include -I/path/programs/mimic_sources_dev/gromacs-2021.6/build/src -I/path/programs/mimic_sources_dev/gromacs-2021.6/src -isystem /path/programs/mimic_sources_dev/gromacs-2021.6/src/external/thread_mpi/include -isystem /path/programs/spack/opt/spack/linux-sles15-zen2/gcc-14.2.0/intel-oneapi-mpi-2021.13.1-uxkmsteetuh4j46e6x5muukdyr4snmb6/mpi/2021.13/include -isystem /path/.local/include -isystem /path/programs/mimic_sources_dev/gromacs-2021.6/src/external -isystem /path/programs/mimic_sources_dev/gromacs-2021.6/src/external/tng_io/include -isystem /path/programs/mimic_sources_dev/gromacs-2021.6/build/tng/include -isystem /path/programs/mimic_sources_dev/gromacs-2021.6/src/external/lmfit --gcc-toolchain=/path/programs/spack/opt/spack/linux-sles15-zen2/gcc-12.3.0/gcc-14.2.0-lzugpkgeuobdiavasko3lpdknlwjqzib -O3 -DNDEBUG -std=c++17 -fPIC -march=core-avx2 -Wno-missing-field-initializers -fno-finite-math-only -fiopenmp -MD -MT src/gromacs/CMakeFiles/libgromacs.dir/analysisdata/dataframe.cpp.o -MF CMakeFiles/libgromacs.dir/analysisdata/dataframe.cpp.o.d -o CMakeFiles/libgromacs.dir/analysisdata/dataframe.cpp.o -c /path/programs/mimic_sources_dev/gromacs-2021.6/src/gromacs/analysisdata/dataframe.cpp
In file included from /path/programs/mimic_sources_dev/gromacs-2021.6/src/gromacs/analysisdata/dataframe.cpp:44:
In file included from /path/programs/mimic_sources_dev/gromacs-2021.6/src/gromacs/analysisdata/dataframe.h:49:
/path/programs/mimic_sources_dev/gromacs-2021.6/src/gromacs/utility/flags.h:126:5: error: unknown type name 'uint64_t'
  126 |     uint64_t flags_;
      |     ^
1 error generated.
make[2]: *** [src/gromacs/CMakeFiles/libgromacs.dir/build.make:6943: src/gromacs/CMakeFiles/libgromacs.dir/analysisdata/dataframe.cpp.o] Error 1
make[2]: Leaving directory '/path/programs/mimic_sources_dev/gromacs-2021.6/build'
make[1]: *** [CMakeFiles/Makefile2:3968: src/gromacs/CMakeFiles/libgromacs.dir/all] Error 2
make[1]: Leaving directory '/path/programs/mimic_sources_dev/gromacs-2021.6/build'
make: *** [Makefile:166: all] Error 2

Does not really matter in this case, but good that you checked!

This time it’s #include <cstdint> in src/gromacs/utility/flags.h, between #define GMX_UTILITY_FLAGS_H and namespace gmx.

If you get any more issues, you can search the unknown symbol at C++ reference - cppreference.com, and then look for the phrase Defined in header at the top of the page. E.g., std::getenv - cppreference.com.

However, newer GROMACS version have it all fixed (at least the two issues you listed so far) and in general has many other improvements. Any reasons you prefer 2021?

1 Like

@al42and Many thanks for your responses. Both solved the problem.
Thanks again
All the best
David