GMLC-TDC / HELICS

Hierarchical Engine for Large-scale Infrastructure Co-Simulation (HELICS)
https://docs.helics.org/en/latest/
BSD 3-Clause "New" or "Revised" License
127 stars 41 forks source link

Unable to build HELICS with AppleClang #2569

Closed trevorhardy closed 11 months ago

trevorhardy commented 11 months ago

Describe the bug Unable to build main branch of HELICS library with AppleClang.

Environment (please complete the following information):

Compile error messages

[ 12%] Building CXX object ThirdParty/utilities/gmlc/utilities/CMakeFiles/gmlc_utilities.dir/vectorOps.cpp.o
[ 13%] Building CXX object ThirdParty/utilities/gmlc/utilities/CMakeFiles/gmlc_utilities.dir/timeStringOps.cpp.o
In file included from /Users/hard312/src/HELICS/HELICS/ThirdParty/utilities/gmlc/utilities/timeStringOps.cpp:11:
In file included from /Users/hard312/src/HELICS/HELICS/ThirdParty/utilities/gmlc/utilities/string_viewConversion.h:21:
In file included from /Users/hard312/anaconda3/include/boost/spirit/home/x3.hpp:14:
In file included from /Users/hard312/anaconda3/include/boost/spirit/home/x3/auxiliary.hpp:11:
In file included from /Users/hard312/anaconda3/include/boost/spirit/home/x3/auxiliary/any_parser.hpp:17:
In file included from /Users/hard312/anaconda3/include/boost/spirit/home/x3/support/traits/move_to.hpp:12:
In file included from /Users/hard312/anaconda3/include/boost/spirit/home/x3/support/traits/attribute_category.hpp:16:
In file included from /Users/hard312/anaconda3/include/boost/spirit/home/x3/support/traits/is_variant.hpp:11:
In file included from /Users/hard312/anaconda3/include/boost/variant.hpp:17:
In file included from /Users/hard312/anaconda3/include/boost/variant/variant.hpp:21:
In file included from /Users/hard312/anaconda3/include/boost/type_index.hpp:29:
In file included from /Users/hard312/anaconda3/include/boost/type_index/stl_type_index.hpp:47:
/Users/hard312/anaconda3/include/boost/container_hash/hash.hpp:131:33: error: no template named 'unary_function' in namespace 'std'; did you mean '__unary_function'?
        struct hash_base : std::unary_function<T, std::size_t> {};
                           ~~~~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__functional/unary_function.h:46:1: note: '__unary_function' declared here
using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>;
^
1 error generated.
make[2]: *** [ThirdParty/utilities/gmlc/utilities/CMakeFiles/gmlc_utilities.dir/timeStringOps.cpp.o] Error 1
make[1]: *** [ThirdParty/utilities/gmlc/utilities/CMakeFiles/gmlc_utilities.dir/all] Error 2
make: *** [all] Error 2
trevorhardy commented 11 months ago

I've done a bit more testing and I'm getting the same error when trying to build v3.3.2 and v3.2.1. Based on the folders I'm seeing in my "install" folder on my computer, I'm fairly certain I have been able to build v3.3.2 on this computer in the past. Maybe this is more an issue with my Boost installation?

phlptp commented 11 months ago

My guess would be some sort of incompatibility between the older version of boost and the newest version of appleClang.

phlptp commented 11 months ago

Hopefully the newer versions of boost fix it

phlptp commented 11 months ago

If need be I think there is a CMake option to disable that bit of code, I can dig that up if you want

trevorhardy commented 11 months ago

This is relevant but I'm still fuzzy on what's going on exactly. Is boost 1.82.0 (I upgraded) not C++17 compatible? https://stackoverflow.com/questions/63577103/what-is-an-equivalent-replacement-for-stdunary-function-in-c17

I'm going to try adding the following option and see if it will build: _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION

trevorhardy commented 11 months ago

OK, I feel foolish: how do I set the flag? I normally just use ccmake to set my build options and (as you might guess) this flag is not one of the options.

phlptp commented 11 months ago

in the HELICS CMAKE set GMLC_UTILITIES_USE_BOOST_SPIRIT=OFF in some way. That will disable that bit of code.

phlptp commented 11 months ago

That flag you were referencing would have to be set in the C++ code, you would have to set it via the CMAKE_CXX_FLAGS

trevorhardy commented 11 months ago

Setting your flag (by editing CMakeCache.txt after generating by running cmake .. and ccmake .), @phlptp, allowed me to build v3.4.0 on my machine. I'm closing this out.