Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Got "/usr/lib64/lib64" while using cmake with boost

Tags:

boost

cmake

I have a cmake controlled package that use FindBoost.cmake to locate boost. Two of my users reported this bug to me, but I cannot reproduce it on my computer.

While solving dependencies of a target executable, the make claims following error:

make[2]: *** No rule to make target `/usr/lib64/lib64/libboost_filesystem-mt.so.5', needed by `src/ht-asm'.  Stop.

I have set the library dirs in my makefile, before adding the target "ht-asm":

link_directories(
    ${Boost_LIBRARY_DIRS}
)

And I have totally no idea on this issue, as I never met them on my computers (one with Debian 6 and the other with Fedora 18).

like image 667
jiandingzhe Avatar asked Jan 19 '14 06:01

jiandingzhe


1 Answers

I found the solution here which worked for cmake 2.8.12.1 with boost 1.41.0-18

  • CMake FIND_PACKAGE succeeds but returns wrong path

Here is the verbatim text ...


The problem is with the boost-devel distributed file: /usr/lib64/boost/Boost-relwithdebinfo.cmake

The cmake-2.6 package does not use this file at all, because the FindBoost.cmake file returns (correct) full paths to boost libraries. The cmake28-2.8.8 FindBoost.cmake file returns library strings like boost_date_time-mt-shared, which are targets defined in /usr/lib64/boost/Boost-relwithdebinfo.cmake.

At the very top of /usr/lib64/boost/Boost-relwithdebinfo.cmake, a variable named _IMPORT_PREFIX is defined from the location of the cmake file itself, and then used like so:

#----------------------------------------------------------------
# Generated CMake target import file for configuration "RelWithDebInfo".
#----------------------------------------------------------------

# Commands may need to know the format version.
SET(CMAKE_IMPORT_FILE_VERSION 1)

# Compute the installation prefix relative to this file.
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)

# Import target "boost_date_time-static" for configuration "RelWithDebInfo"
SET_PROPERTY(TARGET boost_date_time-static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
SET_TARGET_PROPERTIES(boost_date_time-static PROPERTIES
  IMPORTED_LOCATION_RELWITHDEBINFO "${_IMPORT_PREFIX}/lib64/libboost_date_time.a"
  )

This sets _IMPORT_PREFIX to /usr/lib64, which is concatenated with another string that has /lib64/ in it as well. I found that if I simply change the file to include a 3rd GET_FILENAME_COMPONENT call, it works fine. Like so:

#----------------------------------------------------------------
# Generated CMake target import file for configuration "RelWithDebInfo".
#----------------------------------------------------------------

# Commands may need to know the format version.
SET(CMAKE_IMPORT_FILE_VERSION 1)

# Compute the installation prefix relative to this file.
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)

# Import target "boost_date_time-static" for configuration "RelWithDebInfo"
SET_PROPERTY(TARGET boost_date_time-static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
SET_TARGET_PROPERTIES(boost_date_time-static PROPERTIES
  IMPORTED_LOCATION_RELWITHDEBINFO "${_IMPORT_PREFIX}/lib64/libboost_date_time.a"
  )
like image 161
JPS Avatar answered Oct 31 '22 07:10

JPS