[cmake-developers] [CMake 0013249]: Static fortran executables fail to build due to a missing libintlc reference.

Mantis Bug Tracker mantis at public.kitware.com
Fri May 25 14:07:53 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=13249 
====================================================================== 
Reported By:                Travis Horine
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13249
Category:                   CMakeSetup
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-05-25 14:07 EDT
Last Modified:              2012-05-25 14:07 EDT
====================================================================== 
Summary:                    Static fortran executables fail to build due to a
missing libintlc reference.
Description: 
Not 100% sure if this is a bug but thought I should submit it just in case. 

As I understand it, the first time cmake runs it tries to figure out some basic
things like which compiler to use and what the compiler needs by way of basic
flags,etc... I'm not sure why but according to the CMakeOutput.log generated
during this compiler detection phase, cmake is trying to collect an explicit
list of the implicit libraries used by the compiler. It then apparently applies
these implicit libraries explicitly to each target link when the target was
built with the associated compiler. 

Assuming that is what is happening then there may be a problem with that
approach using the Intel 12.0.2 fortran compiler. That compiler reports the
implicit use of a so called 'intlc' library which appears to only exist in
shared object form on my machine. I think the compiler reports this as an
implicit library because CMake is invoking it with the '-i_dynamic' flag (see
cmake-2.8.4/share/cmake-2.8/Modules/Platform/Linux-Intel-Fortran.cmake).
'-i_dynamic' is ostensibly slang for the 'shared-intel' flag. 

Since this -i_dynamic flag causes the intel compiler to report 'intlc' as an
implicit library the -lintlc flag is therefore being explicitly appended to any
link commands even when the '-static' flag is also present. 

Although my executable does not actually need this intlc library (ie...I can
remove it manually from the link line and get a functional static build) the
compiler fails to compile when the '-static' flag is present simply because it
cannot find a static version of the intlc library ie.. 'libintlc.a'

Assuming it is important for CMake to continue to explicitly list the normally
'implicit' libraries on the link lines then there may be a need to weed out
those libraries which do not have static counter parts for a given compiler. At
least, my workaround for this has been to use

LIST(REMOVE_ITEM CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES intlc)

in my CMakeLists.txt file before trying to build the static executable.



Steps to Reproduce: 
basically: Use add_executable to build a fortran executable with
CMAKE_EXE_LINKER_FLAGS set to "-static".

In my case, (maybe this is important) I am building a mixed language executable
where the C++ compiler (icpc) builds an object, the Fortran compiler (ifort)
builds an object and then the C++ compiler (icpc) is invoked for linking the two
objects into a static executable.



Additional Information: 
My CMakeList file is something like this:

SET(CMAKE_EXE_LINKER_FLAGS "-static")
ADD_EXECUTABLE(file file.cpp)
TARGET_LINK_LIBRARIES(file alib blib)

Where alib is a library built in the parent directory and blib is a library
built in a subdirectory of the file.cpp source. 
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-05-25 14:07 Travis Horine  New Issue                                    
======================================================================




More information about the cmake-developers mailing list