View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010813CMakeCMakepublic2010-06-10 06:222016-06-10 14:31
Reporterengels 
Assigned ToBill Hoffman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformLinux 64bitOSRedHatOS Version
Product VersionCMake-2-8 
Target VersionFixed in Version 
Summary0010813: strange behaviour finding libdl.so in 64 bit
DescriptionHi,

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}" )
Steps To Reproduceplease check attached CMakeLists.txt
TagsNo tags attached.
Attached Filestxt file icon CMakeLists.txt [^] (194 bytes) 2010-06-10 06:22 [Show Content]
patch file icon cmake_add_lib64_prefix_for_any_language.patch [^] (577 bytes) 2011-03-18 15:54 [Show Content]

 Relationships

  Notes
(0021026)
Rolf Eike Beer (developer)
2010-06-16 06:56

Whatever the reason for that is: why don't you use CMAKE_CL_LIBS?
(0021028)
engels (reporter)
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 (reporter)
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 (administrator)
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.

 Issue History
Date Modified Username Field Change
2010-06-10 06:22 engels New Issue
2010-06-10 06:22 engels File Added: CMakeLists.txt
2010-06-16 06:56 Rolf Eike Beer Note Added: 0021026
2010-06-16 08:38 engels Note Added: 0021028
2010-06-16 08:39 engels Note Edited: 0021028
2010-08-12 06:01 engels Note Edited: 0021028
2011-01-17 16:42 David Cole Assigned To => Bill Hoffman
2011-01-17 16:42 David Cole Status new => assigned
2011-03-18 15:54 Peter Colberg Note Added: 0025824
2011-03-18 15:54 Peter Colberg File Added: cmake_add_lib64_prefix_for_any_language.patch
2016-06-10 14:28 Kitware Robot Note Added: 0041709
2016-06-10 14:28 Kitware Robot Status assigned => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team