在Cmake中显式设置后链接不正确的动态库

时间:2015-10-19 14:13:12

标签: linux matlab boost cmake ros

我现在有一个非常令人沮丧的问题。我正在尝试构建一个使用ROS和已编译的Matlab .so文件的可执行文件。由于我认为是一个提升冲突,我正在尝试使用早期版本的boost来构建此exe。现在,我已经设置了cmakelist文件,运行catkin_make(作为它的一个ros项目)并且所有内容都编译完成,并且可以看到正确的boost版本。

但是,在编译的exe上运行ldd时,它似乎仍然链接到更新的版本。它相当烦人。我发布了cmakelists文件和ldd结果。我的系统是带有ROS Indigo的Ubuntu 14.04。

任何帮助都会非常好,因为我正在试着弄清楚出了什么问题!

非常感谢提前!

##CMAKE FILE

cmake_minimum_required(VERSION 2.8.3)
project(testmatlabdll)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors -O4 -march=native")
add_definitions(-std=c++11)

find_package(catkin REQUIRED)

find_package(PCL 1.7 REQUIRED)
link_directories(${PCL_LIBRARY_DIRS})
include_directories(${PCL_INCLUDE_DIRS})
add_definitions(${PCL_DEFINITIONS})

set(Boost_NO_SYSTEM_PATHS ON)
set(BOOST_ROOT /home/devbot/Downloads/boost_1_50_0)
set(BOOST_DIR /home/devbot/Downloads/boost_1_50_0)
set(Boost_INCLUDE_DIR /home/devbot/Downloads/boost_1_50_0)
set(BOOST_INCLUDEDIR /home/devbot/Downloads/boost_1_50_0)
set(Boost_USE_STATIC_LIBS   OFF)
set(Boost_USE_MULTITHREADED ON)

message(STATUS "BOOST_ROOT = ${BOOST_ROOT}")
message(STATUS "Boost_VERSION = ${Boost_VERSION}")
message(STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}")
message(STATUS "Boost_MAJOR_VERSION = ${Boost_MAJOR_VERSION}")
message(STATUS "Boost_MINOR_VERSION = ${Boost_MINOR_VERSION}")
message(STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}")
message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARY_DIRS = ${Boost_LIBRARY_DIRS}")

find_package(Boost COMPONENTS REQUIRED
              system filesystem thread date_time iostreams serialization chrono)

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation image_transport cv_bridge)

find_package(OpenCV REQUIRED)

catkin_package(CATKIN_DEPENDS roscpp
                              std_msgs
                              pcl_ros
                              sensor_msgs
                              cv_bridge
                              message_runtime
               LIBRARIES      ${PROJECT_NAME}
               DEPENDS        system_lib)


include_directories(include ${catkin_INCLUDE_DIRS})
include_directories(${OpenCV_INCLUDE_DIRS})

include_directories(/usr/local/MATLAB/R2013b/extern/include/)
include_directories(/opt/matlab/extern/include)
include_directories(/home/devbot/catkin_ws/src/testmatlabdll/src)
link_directories(/home/devbot/catkin_ws/src/testmatlabdll/src)

add_library(mwmc SHARED IMPORTED) 
set_property(TARGET mwmc PROPERTY IMPORTED_LOCATION /usr/local/MATLAB/MATLAB_Compiler_Runtime/v82/runtime/glnxa64/libmwmclmcrrt.so)

add_executable(testMatlab src/testMatlab.cpp)

target_link_libraries(testMatlab ${Boost_LIBRARIES} ${catkin_LIBRARIES}  ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
target_link_libraries(testMatlab roughlib mwmc)

从LDD输出

ldd testMatlab | grep boost
    libboost_system.so.1.50.0 => /home/devbot/Downloads/boost_1_50_0/stage/lib/libboost_system.so.1.50.0 (0x00007f7456f8a000)
    libboost_system.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0 (0x00007f7454662000)
    libboost_thread.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.54.0 (0x00007f745444c000)
    libboost_filesystem.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.54.0 (0x00007f7454018000)
    libboost_regex.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0 (0x00007f744d5d8000)

0 个答案:

没有答案