0

I am new to fortran and cmake, so I'm sure there is a simple fix I am missing! error message:

100%] Linking Fortran executable dynamicmpm
CMakeFiles/dynamicmpm.dir/Solver.FOR.o: In function `modsolver_mp_createprofiledss_':
Solver.FOR:(.text+0x1143): undefined reference to `dss_create_'
Solver.FOR:(.text+0x11a8): undefined reference to `dss_define_structure_'
Solver.FOR:(.text+0x1471): undefined reference to `dss_reorder_'
CMakeFiles/dynamicmpm.dir/Solver.FOR.o: In function `modsolver_mp_solveequations_':
Solver.FOR:(.text+0x35ec): undefined reference to `dss_factor_real_d__'
Solver.FOR:(.text+0x361d): undefined reference to `dss_solve_real_d_'
CMakeFiles/dynamicmpm.dir/Solver.FOR.o: In function `modsolver_mp_destroyequations_':
Solver.FOR:(.text+0x4495): undefined reference to `dss_delete_'
CMakeFiles/dynamicmpm.dir/Solver.FOR.o: In function `modsolver_mp_initialisereducedsolution_':
Solver.FOR:(.text+0x5a58): undefined reference to `dss_create_'
Solver.FOR:(.text+0x5abd): undefined reference to `dss_define_structure_'
Solver.FOR:(.text+0x606d): undefined reference to `dss_reorder_'

I included use mkl_dss at the top of the Solver.FOR file

inside the cmakefile:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(MPM)

enable_language (Fortran)

set(CMAKE_Fortran_COMPILER_ID "GNU")

add_compile_options(-nologo -O2 -ldl -assume buffered_io -fpp -Dinternal_release
        -reentrancy threaded -free -warn all -real_size 64 -Qauto -fp:strict
        -fp:constant -libs:static -threads -Qmkl:sequential -Qm64
        -fmax-identifier-length=63 -ffree-form -ffree-line-length-none -fdefault-real-8)

set(SRCS MOHRStrainSoftening.FOR getversion.for GlobalConstants.FOR mkl_dss.f90 String.for
    Feedback.for FileIO.for MatrixMath.FOR timing.for ISORT.FOR GeoMath.FOR Counters.FOR
    ElemCalcTETRA.FOR ReadCalculationData.FOR ElemCalcQUAD.FOR InitialiseKernel.FOR
    ElemCalcTRI.FOR ReadMaterialData.FOR ElemCalc.FOR Particle.FOR MeshInfo.FOR
    ElemConnections.FOR RotBoundCond.FOR ReadGeometryData.FOR InitialiseElementType.for
    Solver.FOR MPMData.FOR WriteMPMData.FOR WriteVTKASCII.FOR TwoLayerFormulation.FOR
    MPMDYNUnsatConsolidation.FOR WriteVTKBinary.FOR MPMStrainSmoothing.FOR WriteVTKOutput.FOR
    MPMDYNConsolidation.FOR MPMStresses.FOR MPMDynContact.FOR MPMDynViscousBoundary.FOR
    WriteTestData.FOR Liquid.FOR WriteVTK2Layer.FOR ReadMPMData.FOR RigidBody.f WriteNodalData.FOR
    MPMMeshAdjustment.FOR MPMEmptyElements.FOR WriteResultData.FOR MPMConvPhase.FOR
    ErrorHandler.for AdjustParticleDiscretisation.FOR MPMExcavation.FOR MPMInit.FOR MPMDYNBTSig.FOR
    LagrangianPhase.FOR MPMDYNStresses.FOR MPMDYNConvPhase.FOR MPMQuasiStaticImplicit.FOR
    MPMDynamicExplicit.FOR Kernel.for GetStrain.FOR Anura3D.for FORMDE.FOR BuildLoad.FOR
    BuildDElastic.FOR MOHR.FOR BuildBJacDet.FOR PRNSTR.FOR GetPrinStress.FOR)

add_executable(dynamicmpm ${SRCS})

I'm sure I am just not linking it properly but I can't seem to find the mistake. I include mkl_dss.f90 in SRCS and have the appropriate use statement in SOLVER.FOR

I am including a link to my previous SO post in case that might be useful: Executable file does not exist after compiling Fortran code

Sam Hinkie
  • 27
  • 5
  • "I'm sure I am just not linking it properly" - you appear not to have set _any_ link targets? Ignoring CMake, do you know how to build your project manually? If so, can you add the various linker options you use? – francescalus Aug 04 '21 at 19:07
  • The short answer to your question is "no", I am new to trying to build projects through linux. Compiling through Virtual Studio is as simple as clicking a few buttons, I am not sure which lines I need to add in order for the correct libraries to link together – Sam Hinkie Aug 04 '21 at 19:11
  • does the second to last line `set(SRCS srcA.FOR srcB.FOR ...)` not link everything? @francescalus ? – Sam Hinkie Aug 04 '21 at 19:21
  • The `set(SRCS ...`) leads to linking the objects created from those Fortran source files, but you need to also link against the MKL library object (which isn't one of your project source files). See [this answer](https://stackoverflow.com/a/66860223/3157076) for some detail about linking external libraries (although it doesn't relate to CMake). – francescalus Aug 04 '21 at 19:35
  • You'll need something [like this](https://stackoverflow.com/q/8774593/3157076). – francescalus Aug 04 '21 at 19:36

0 Answers0