[CMake] Missing -lgfortran with FortranCInterface verify calls

Daniel Wirtz daniel.wirtz at simtech.uni-stuttgart.de
Thu Aug 27 03:24:25 EDT 2015


Hey all,

i'm encountering link errors on C-Fortran interface verification on 
MSYS2 (fully updated) / MinGW (x86_64-4.9.2-posix-seh-rt_v4-rev2) / 
CMake 3.3.0.
Here's a minimal example:

cmake_minimum_required(VERSION 3.0 FATAL_ERROR)

project(C_Fortran_Mingw VERSION 1.0 LANGUAGES C Fortran)

include(FortranCInterface)

FortranCInterface_VERIFY()


this fails with link errors

D:/MSYS2_64/mingw64/bin/gcc.exe  -O3 -DNDEBUG   -Wl,--whole-archive CMakeFiles/VerifyFortranC.dir/objects.a -Wl,--no-whole-archive  -o VerifyFortranC.exe -Wl,--out-implib,libVerifyFortranC.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/VerifyFortranC.dir/linklibs.rsp

libVerifyFortran.a(VerifyFortran.f.obj):VerifyFortran.f:(.text+0x35): undefined reference to `_gfortran_st_write'

libVerifyFortran.a(VerifyFortran.f.obj):VerifyFortran.f:(.text+0x4a): undefined reference to `_gfortran_transfer_character_write'

libVerifyFortran.a(VerifyFortran.f.obj):VerifyFortran.f:(.text+0x52): undefined reference to `_gfortran_st_write_done'


after checking, the @CMakeFiles/VerifyFortranC.dir/linklibs.rsp does not 
contain the "-lgfortran" library include, hence the fuss.
however, while that might fix the issue, i've found no way to tell the 
FortranCInterface scripts to add that, and  following Brad's argumentation
in 
http://cmake.3232098.n2.nabble.com/mixing-c-fortran-missing-gfortran-sometimes-td5563701.html, 
CMake should pick those things up automatically.

so am i missing something obvious here or is this still an (mingw-only) 
issue?
to be clear, i can just skip the verification tests and everything 
works, but i'd like to think that if that is the case the

FortranCInterface_VERIFY()

should work as well.

thanks!
Daniel

-- 
Dr. Daniel Wirtz
Dipl. Math. Dipl. Inf.
SRC SimTech
Pfaffenwaldring 5a, D-70569 Stuttgart
+49 (711) 685-60044



More information about the CMake mailing list