MantisBT - CMake
View Issue Details
0010813CMakeCMakepublic2010-06-10 06:222016-06-10 14:31
engels 
Bill Hoffman 
normalminoralways
closedmoved 
Linux 64bitRedHat
CMake-2-8 
 
0010813: strange behaviour finding libdl.so in 64 bit
Hi,

when using FIND_LIBRARY to find libdl.so in a 64 bit system I stumbled over a very strange problem. CMake finds the 32bit library instead of the 64bit if I specify CXX as the project language, i.e.:

PROJECT( foo ) # works fine (finds /usr/lib64/libdl.so)
PROJECT( foo C ) # works fine (finds /usr/lib64/libdl.so)
PROJECT( foo CXX ) # error: finds /usr/lib/libdl.so
FIND_LIBRARY( DL_LIB NAMES ${CMAKE_DL_LIBS} )
MESSAGE( STATUS "using dl library: ${DL_LIB}" )
please check attached CMakeLists.txt
No tags attached.
txt CMakeLists.txt (194) 2010-06-10 06:22
https://public.kitware.com/Bug/file/3178/CMakeLists.txt
patch cmake_add_lib64_prefix_for_any_language.patch (577) 2011-03-18 15:54
https://public.kitware.com/Bug/file/3759/cmake_add_lib64_prefix_for_any_language.patch
Issue History
2010-06-10 06:22engelsNew Issue
2010-06-10 06:22engelsFile Added: CMakeLists.txt
2010-06-16 06:56Rolf Eike BeerNote Added: 0021026
2010-06-16 08:38engelsNote Added: 0021028
2010-06-16 08:39engelsNote Edited: 0021028
2010-08-12 06:01engelsNote Edited: 0021028
2011-01-17 16:42David ColeAssigned To => Bill Hoffman
2011-01-17 16:42David ColeStatusnew => assigned
2011-03-18 15:54Peter ColbergNote Added: 0025824
2011-03-18 15:54Peter ColbergFile Added: cmake_add_lib64_prefix_for_any_language.patch
2016-06-10 14:28Kitware RobotNote Added: 0041709
2016-06-10 14:28Kitware RobotStatusassigned => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0021026)
Rolf Eike Beer   
2010-06-16 06:56   
Whatever the reason for that is: why don't you use CMAKE_CL_LIBS?
(0021028)
engels   
2010-06-16 08:38   
(edited on: 2010-08-12 06:01)
Hi Rolf,

you mean CMAKE_DL_LIBS ?
due to the CMake Policy Warning CMP003 that I get using cmake 2.6:

#-----------------------------------------------------------
CMake Warning (dev) at src/CMakeLists.txt:47 (ADD_LIBRARY):
  Policy CMP0003 should be set before this line. Add code such as

    if(COMMAND cmake_policy)
      cmake_policy(SET CMP0003 NEW)
    endif(COMMAND cmake_policy)

  as early as possible but after the most recent call to
  cmake_minimum_required or cmake_policy(VERSION). This warning appears
  because target "lib_RAIDA" links to some libraries for which the linker
  must search:

    dl

  and other libraries with known full path:

    /afs/desy.de/group/it/ilcsoft/root/5.26.00b/lib/libCore.so

  CMake is adding directories in the second list to the linker search path in
  case they are needed to find libraries from the first list (for backwards
  compatibility with CMake 2.4). Set policy CMP0003 to OLD or NEW to enable
  or disable this behavior explicitly. Run "cmake --help-policy CMP0003" for
  more information.
This warning is for project developers. Use -Wno-dev to suppress it.
#-----------------------------------------------------------


The reason I am looking for the dl library is because I am trying to write a find module for a package ( http://root.cern.ch [^] ) that includes a command line tool "root-config" which returns something like:
-L/opt/products/root/5.14.00/lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -pthread -lm -ldl -rdynamic

(0025824)
Peter Colberg   
2011-03-18 15:54   
I have hit a bug with the same origin as the one reported above. In a CXX-only project, FindLua51.cmake fails to find the math library if its path is /usr/lib64/libm.so.

Here is a minimal code:

cmake_minimum_required(VERSION 2.8)
project(HALMD CXX)
# reproduces failure of FindLua51.cmake
find_library(LUA_MATH_LIBRARY m)
message("${LUA_MATH_LIBRARY}")

Here is the result:

-- The CXX compiler identification is GNU
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
LUA_MATH_LIBRARY-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pcolberg/tmp/find_library/build

The origin of this bug lies cmFindLibraryCommand::AddLib64Paths(). Strangely this function returns if the C language is not enabled. Is there any specific reason why you would not want find_library to look into lib64 path suffixes if _not_ using C, e.g. C++ or Fortran?

I attached a proposed patch which removes this check.

For those stumbling upon the same bug with CXX as the only project language: Until CMake is fixed upstream, you can use PATH_SUFFIXES to manually add lib64, e.g.

find_library(LUA_MATH_LIBRARY m PATH_SUFFIXES lib64 lib)
(0041709)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.