KratosMultiphysics / Kratos

Kratos Multiphysics (A.K.A Kratos) is a framework for building parallel multi-disciplinary simulation software. Modularity, extensibility and HPC are the main objectives. Kratos has BSD license and is written in C++ with extensive Python interface.
https://kratosmultiphysics.github.io/Kratos/
Other
1.04k stars 246 forks source link

Compilation failing #10262

Open rlrangel opened 2 years ago

rlrangel commented 2 years ago

I recently started getting an error when compiling Kratos on my laptop.

It happens in the master branch, apparently with any application, as shown in the image below.

The error says the following message and repeats many times: "error C2737: 'pybind11::overload_cast': the object 'constexpr' must be initialized".

I tried to delete Kratos and clone it again, and also change the C++ Language Standard to C++17 in Visual Studio, but the error persists.

I'm using Windows 10, Python 3.9, Cmake 3.18, Boost 1.73.

In the end is the configuration file that I use to compile the PFEM Application.

Let me know if there is more information I can provide.

image

rem Set compiler
set CC=cl.exe
set CXX=cl.exe

rem Set variables
set KRATOS_SOURCE=~0,-1%/..
set KRATOS_BUILD=%KRATOS_SOURCE%/build
set KRATOS_APP_DIR=applications

rem Set basic configuration
set KRATOS_BUILD_TYPE=Debug
set BOOST_ROOT=C:\Program Files\Boost\boost_173
set PYTHON_EXECUTABLE=C:\Program Files\Python\Python_39\python.exe

rem Set applications to compile
set KRATOS_APPLICATIONS=
CALL :add_app %KRATOS_APP_DIR%\LinearSolversApplication;
CALL :add_app %KRATOS_APP_DIR%\DelaunayMeshingApplication;
CALL :add_app %KRATOS_APP_DIR%\PfemFluidDynamicsApplication;
CALL :add_app %KRATOS_APP_DIR%\ConvectionDiffusionApplication;

rem Clean
del /F /Q "%KRATOS_BUILD%\%KRATOS_BUILD_TYPE%\cmake_install.cmake"
del /F /Q "%KRATOS_BUILD%\%KRATOS_BUILD_TYPE%\CMakeCache.txt"
del /F /Q "%KRATOS_BUILD%\%KRATOS_BUILD_TYPE%\CMakeFiles"

rem Configure
@echo on
cmake -G"Visual Studio 16 2019" -H"%KRATOS_SOURCE%" -B"%KRATOS_BUILD%\%KRATOS_BUILD_TYPE%"  ^
-DUSE_EIGEN_MKL=OFF                                       ^
-DUSE_TRIANGLE_NONFREE_TPL=ON                             ^
-DUSE_TETGEN_NONFREE_TPL=ON                               ^
-DCMAKE_CXX_FLAGS=" -D_SCL_SECURE_NO_WARNINGS /MP "

rem Build
cmake --build "%KRATOS_BUILD%/%KRATOS_BUILD_TYPE%" --target install -- /property:configuration=%KRATOS_BUILD_TYPE% /p:Platform=x64
goto:eof

rem Function to add apps
:add_app
set KRATOS_APPLICATIONS=%KRATOS_APPLICATIONS%%1;
goto:eof
roigcarlo commented 2 years ago

Hi @rlrangel

I am aware of the error, we are trying to find a final solution but so fair I only can give you this workaround:

1 - In pybind11/detail/common.h (line 1035) change:

template <typename... Args>
#    if (defined(_MSC_VER) && _MSC_VER < 1920) /* MSVC 2017 */                                    \
        || (defined(__clang__) && __clang_major__ == 5)
static constexpr detail::overload_cast_impl<Args...> overload_cast = {};
#    else
static constexpr detail::overload_cast_impl<Args...> overload_cast;
#    endif

To

template <typename... Args>
static constexpr detail::overload_cast_impl<Args...> overload_cast = {};

The error is external to Kratos and I suspect the problem is a bad èvaluation on the _MSC_VER < 1920.

I will ping once we have a more robust solution, but until then this should allow you to compile the code.

rlrangel commented 2 years ago

Thank you @roigcarlo

philbucher commented 2 years ago

Is this known in pybind?

If not I would also open sn issue there

roigcarlo commented 2 years ago

Doubt it, I found it last friday in one of my machines. Feel free to open ( I am in a course and I can not fill a proper report )

The issue is exactly the described here.