memilio
memilio copied to clipboard
Boost headers conflict with install boost library
Bug description
On the SC HPDA Cluster, the build fails with an error in boost libraries if the boost module is loaded.
Version
Linux
To reproduce
module load PrgEnv/gcc11-openmpi(loads compiler, etc. but also boost libraries)- build memilio as normal
Relevant log output
error: declaration of 'const boost::system::error_category& boost::filesystem::codecvt_error_category()' has a different exception specifier
70 | BOOST_FILESYSTEM_DECL const boost::system::error_category& codecvt_error_category()
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/abel_da/memilio/cpp/build/boost_1_75_0/libs/filesystem/src/codecvt_error_category.cpp:16:
/scratch/spack-22.2/opt/spack/linux-ubuntu20.04-skylake_avx512/gcc-11.3.0/boost-1.79.0-44fkepcperfvnjfzugsukpqidlsmmyfh/include/boost/filesystem/path_traits.hpp:32:53: note: from previous declaration 'const boost::system::error_category& boost::filesystem::codecvt_error_category() noexcept'
32 | BOOST_FILESYSTEM_DECL system::error_category const& codecvt_error_category() BOOST_NOEXCEPT;
| ^~~~~~~~~~~~~~~~~~~~~~
Add any relevant information, e.g. used compiler, screenshots.
No response
Checklist
- [X] Attached labels, especially loc:: or model:: labels.
- [X] Linked to project
This happens because the headers from the boost module are used ahead of the boost headers included with memilio. Note the two different boost include paths in the error message.
Workaround:
- remove the
SYSTEMflag fromtarget_include_directories(boost SYSTEM INTERFACEin cpp/cmake/BuildBoost.cmake that we added in #787 - disable compiler warnings by commenting out the area around
MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORSin cpp/CMakeLists.txt
Explanation:
The boost module sets the CPATH environment variable. CPATH is equivalent to the -I compile flag, whereas target_include_directories(... SYSTEM) adds -isystem. -I has a higher priority than -isystem, so the module headers are found.
Real Solutions?:
- maybe this should not be considered a bug of memilio? It's only on some systems and there is a workaround, so may be safe to ignore.
- don't set the
SYSTEMflag in CMake, treat warnings from boost manually? - change the modulefiles to not set the CPATH variable? May have sideeffects for other users of the modules. There is an option in spack to not set CPATH or to set C_INCLUDE_PATH and CPLUS_INCLUDE_PATH instead of CPATH. the latter two variables are treated as
-isystemunlike CPATH. (https://spack.readthedocs.io/en/latest/module_file_support.html#)
Disabling the compiler warnings seems not enough, it still results in the error.