-1

I am compiling using cmake. I am on Linux with an intel processor. The important cmake lines are

set(SRCS srcA.FOR srcB.FOR ... srcK.FOR)
add_executable(filename ${SRCS})

I get no errors, just warnings. There are three types of warnings:

  1. I am not using a variable (bad on my part but surely not code-breaking)
  2. "this name has not been given a specific type"
  3. "no action performed for file 'path/to/file/filename.FOR.o'"

Right before the "no action..." warning it says

Linking Fortran executable filename

and the last line says

Built target filename

That last line in particular to me implies that there should be an executable file, but I cannot find it. I have tried searching for it using find -type f -name "*.exe" and `find -type f -name "filename" and neither are returning anything.

I will note that I am new to compiling these types of files on Linux, so I am sure there is something small I am doing wrong and don't know what it is

EDIT Added more detailed error output Note that the "no action performed..." error appears once for each file and is identical (besides the filename of course)

ifort: warning #10145: no action performed for file 'CMakeFiles/dynamicmpm.dir/getversion.for.o'

EDIT #2 Adding the contents of the cmake file below

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(MPM)

enable_language (Fortran)

get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)

MESSAGE("Fortran_COMPILER_NAME = ${Fortran_COMPILER_NAME}")


set(CMAKE_Fortran_FLAGS "-nologo -O2 -assume buffered_io -fpp -Dinternal_release -reentrancy threaded -free -warn all -real_size 64 -Qauto -fp:strict -fp:constant -libs:static -threads -Qmkl:sequential -c -Qm64") 


if (Fortran_COMPILER_NAME MATCHES "gfortran")
  # gfortran
  set(COMMON_FLAGS "-fmax-identifier-length=63 -ffree-form -ffree-line-length-none -fdefault-real-8")
  set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} ${COMMON_FLAGS}")
  set (CMAKE_Fortran_FLAGS_DEBUG   "${CMAKE_Fortran_FLAGS_DEBUG} ${COMMON_FLAGS}")
endif()

set(SRCS srcA.FOR srcB.FOR ... srcK.FOR) #theres a bazillion files so I made this dummy line for the post
add_executable(filename ${SRCS})

EDIT 3

I get the following error now after making the changes recommended below:

[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_'

at the top of Solver.FOR I have use mkl_dss and mkl_dss.f90 is included in set(SRCS srcA.FOR srcB.for mkl_dss.f90 ... otherSources.FOR)

Am I linking the files incorrectly?

Sam Hinkie
  • 27
  • 5
  • 1
    Searching for `*.exe` on Linux has a little sense: Unlike to Windows, on Linux an executable has no `.exe` extension. – Tsyvarev Aug 03 '21 at 20:21
  • 3
    "I am not using a variable (bad on my part but surely not code-breaking)" - fix the problem and build the project again. "this name has not been given a specific type", "no action performed for file 'path/to/file/filename.FOR.o'" - Please, copy paste the **exact** output into the question post. You may format the output as a code, using `Ctrl+K` or `{}` button. Usually, putting exact output into the question post is much more informative than *describing* that output. – Tsyvarev Aug 03 '21 at 20:23
  • I added the no action error messages above and am working on the unused variable ones as well. I should have mentioned that the code DOES compile fine on Windows, but I am trying to get it to build on Linux as well. This leads me to believe the issue is how I am linking the files, NOT in the code itself. My fault for not mentioning that sooner. – Sam Hinkie Aug 03 '21 at 20:32
  • It is odd you are getting filename.for.o, most builds use filename.o. Did you do a lot of cmake changes? We might need to see more of your cmake file – Cocofalco Aug 04 '21 at 04:05
  • @Cocofalco what in the cmake file would cause that? Do you have any ideas? – Sam Hinkie Aug 04 '21 at 05:08
  • I added the contents of the cmake file @Cocofalco – Sam Hinkie Aug 04 '21 at 05:12

1 Answers1

1

no action performed for file 'path/to/file/filename.FOR.o' - You passed -c to flags, so compiler does not know what to do with object files. Research what -c flag means. Remove -c flag.

get_filename_component (Fortran_COMPILER_NAME - use CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" instead.

Do not use set(CMAKE_Fortran_FLAGS. Prefer target_compiler_options, target_link_options, target_link_libraries or add_compile_options instead.

Do not write long lines. Split them with newlines as a list.

set(COMMON_FLAGS - if they are common, why add them to _RELEASE and _DEBUG separately? Just add_compile_options them.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • I am brand new to all of this so I cannot say thank you enough!! This was so helpful, I'll work on those changes the second I get the chance. – Sam Hinkie Aug 04 '21 at 16:03
  • I edited the question to reflect the current error, it appears to be something with how I am linking libraries I think but I can't quite seem to pin it down. Any help would be appreciated! – Sam Hinkie Aug 04 '21 at 18:00
  • https://meta.stackoverflow.com/questions/266767/what-is-the-the-best-way-to-ask-follow-up-questions Remember to create an [MCVE]. Also compile with verbose build `cmake --build --verbose` and post/inspect the compiler line. I suspect `libs:static` - anyway, _debug_ that manual way - remove lines until you are left with the minimal [MCVE], and then with minimum you'll know what's wrong... The same way you could have found `-c` - by removing stuff. – KamilCuk Aug 04 '21 at 18:07