USCiLab / cereal

A C++11 library for serialization
BSD 3-Clause "New" or "Revised" License
4.17k stars 751 forks source link

Compilation Failures when indirectly linking with Lapack #828

Open GenieTim opened 1 month ago

GenieTim commented 1 month ago

I am working on a project that uses the Eigen library, which in turn uses the Lapack library if available. My project also uses the Cereal library, which in turn uses rapidjson.

Since having installed Lapack, I cannot compile my project anymore on certain platforms, as long as I include both Cereal as well as Lapack.

Here is the error:

FAILED: CMakeFiles/main.dir/main.cpp.o 
/opt/homebrew/bin/g++-14 -DEIGEN_USE_LAPACKE -I/Users/.../cereal-eigen-mre/vendor/cereal/src/cerealLib/include -isystem /opt/homebrew/include/eigen3 -std=gnu++20 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -fopenmp -MD -MT CMakeFiles/main.dir/main.cpp.o -MF CMakeFiles/main.dir/main.cpp.o.d -o CMakeFiles/main.dir/main.cpp.o -c /Users/.../cereal-eigen-mre/main.cpp
In file included from /opt/homebrew/Cellar/gcc/14.1.0_2/include/c++/14/complex.h:38,
                 from /opt/homebrew/include/eigen3/Eigen/src/misc/lapacke.h:75,
                 from /opt/homebrew/include/eigen3/Eigen/LU:34,
                 from /opt/homebrew/include/eigen3/Eigen/Dense:2,
                 from /Users/.../cereal-eigen-mre/main.cpp:3:
/Users/.../cereal-eigen-mre/vendor/cereal/src/cerealLib/include/cereal/external/rapidjson/document.h:1989:16: error: expected identifier before '(' token
 1989 |         struct I {
      |                ^
/Users/.../cereal-eigen-mre/vendor/cereal/src/cerealLib/include/cereal/external/rapidjson/document.h:1989:16: error: expected unqualified-id before '__extension__'
 1989 |         struct I {
      |                ^
/Users/.../cereal-eigen-mre/vendor/cereal/src/cerealLib/include/cereal/external/rapidjson/document.h:1989:16: error: expected ')' before '__extension__'
 1989 |         struct I {
      |                ^
In file included from /Users/.../cereal-eigen-mre/vendor/cereal/src/cerealLib/include/cereal/archives/json.hpp:67,
                 from /Users/.../cereal-eigen-mre/main.cpp:6:
/Users/.../cereal-eigen-mre/vendor/cereal/src/cerealLib/include/cereal/external/rapidjson/document.h:1992:10: error: 'i' does not name a type
 1992 |         }i;
      |          ^
/Users/.../cereal-eigen-mre/vendor/cereal/src/cerealLib/include/cereal/external/rapidjson/document.h: In instantiation of 'double rapidjson::GenericValue<Encoding, Allocator>::GetDouble() const [with Encoding = rapidjson::UTF8<>; Allocator = rapidjson::MemoryPoolAllocator<>]':
/Users/.../cereal-eigen-mre/vendor/cereal/src/cerealLib/include/cereal/archives/json.hpp:663:119:   required from here
  663 |       void loadValue(float & val)       { search(); val = static_cast<float>(itsIteratorStack.back().value().GetDouble()); ++itsIteratorStack.back(); }
      |                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/Users/.../cereal-eigen-mre/vendor/cereal/src/cerealLib/include/cereal/external/rapidjson/document.h:1755:79: error: 'const union rapidjson::GenericValue<rapidjson::UTF8<> >::Number' has no member named 'i'
 1755 |         if ((data_.f.flags & kIntFlag) != 0)                   return data_.n.i.i; // int -> double
      |                                                                       ~~~~~~~~^
ninja: build stopped: subcommand failed.

Here is my platform information:

Another platform where I managed to get this error was on an Ubuntu machine with a recent Intel OneAPI compiler.

And finally, a project you can simply clone and try to build (with build.sh on an appropriate platform): GenieTim/cereal-eigen-mre (might require you to first install openblas or something such that lapack is findable afterwards. It also builds if Lapack is not found!)

I admit, I am not quite sure whether this has to be posted on rapidjson's GitHub instead, but since the version you are using seems heavily outdated, it would not quite feel right there.

redchairman commented 1 month ago

您的邮件我已收到,谢谢合作!