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.01k stars 244 forks source link

Compilation error in Windows #2729

Closed Vahid-Galavi closed 6 years ago

Vahid-Galavi commented 6 years ago

@roigcarlo @pooyan-dadvand

PoromechanicsApps and GeoMechanicsApps give the same error in Windows. They are compiled fine on Linux. I am using Visual Studion 2017. Any idea, what can cause this error?

2> Creating library D:/Libraries/FEM/Kratos/cmake_build64/applications/PoromechanicsApplication/Release/KratosPoromechanicsApplication.lib and object D:/Libraries/FEM/Kratos/cmake_build64/applications/PoromechanicsApplication/Release/KratosPoromechanicsApplication.exp

2>poromechanics_python_application.obj : error LNK2019: unresolved external symbol "public: cdecl Kratos::KratosPoromechanicsApplication::KratosPoromechanicsApplication(void)" (??0KratosPoromechanicsApplication@Kratos@@QEAA@XZ) referenced in function "public: class pybind11::handle cdecl ::operator()(struct pybind11::detail::function_call &)const " (??R@@QEBA?AVhandle@pybind11@@AEAUfunction_call@detail@2@@Z)

2>D:\Libraries\FEM\Kratos\cmake_build64\applications\PoromechanicsApplication\Release\KratosPoromechanicsApplication.pyd : fatal error LNK1120: 1 unresolved externals

2>Done building project "KratosPoromechanicsApplication.vcxproj" -- FAILED.

1>geo_mechanics_python_application.cpp

1> Creating library D:/Libraries/FEM/Kratos/cmake_build64/applications/GeoMechanicsApplication/Release/KratosGeoMechanicsApplication.lib and object D:/Libraries/FEM/Kratos/cmake_build64/applications/GeoMechanicsApplication/Release/KratosGeoMechanicsApplication.exp

1>geo_mechanics_python_application.obj : error LNK2019: unresolved external symbol "public: cdecl Kratos::KratosGeoMechanicsApplication::KratosGeoMechanicsApplication(void)" (??0KratosGeoMechanicsApplication@Kratos@@QEAA@XZ) referenced in function "public: void cdecl ::operator()(struct pybind11::detail::value_and_holder &)const " (??R@@QEBAXAEAUvalue_and_holder@detail@pybind11@@@Z)

1>D:\Libraries\FEM\Kratos\cmake_build64\applications\GeoMechanicsApplication\Release\KratosGeoMechanicsApplication.pyd : fatal error LNK1120: 1 unresolved externals

1>Done building project "KratosGeoMechanicsApplication.vcxproj" -- FAILED.

roigcarlo commented 6 years ago

Yes, it is a visibility problem, for security reasons msvc do not expose any symbol while compiling a DLL, so we need to manually add it.

Both errors means basically that the application core is not visible.

You have to change: https://github.com/KratosMultiphysics/Kratos/blob/master/applications/PoromechanicsApplication/poromechanics_application.h#L70

and the corresponding file in the Geomechanins app so the simbol is exported through the KRATOS_API() macro like that:

class KRATOS_API(POROMECHANICS_APPLICATION) KratosPoromechanicsApplication : public KratosApplication
{
     // code 
}

Make sure that in the geomechanics application you have the following line in the CMake.txt File:

set_target_properties( KratosGeomechanicsCore PROPERTIES COMPILE_DEFINITIONS "GEOMECHANICS_APPLICATION=EXPORT,API")

If it does not work, please tell me the branch you are working on and I'll try to push the fix tomorow

Vahid-Galavi commented 6 years ago

Thank you very much for your prompt reply.

Yes, it works!

ipouplana commented 6 years ago

Thanks @roigcarlo !!