2016-04-20 29 views
1

簡介

我想編譯一個使用ICU和libboost的代碼。爲此,我正在使用以下install.sh文件。問題是,我收到此錯誤:libicuuc.so.52,需要libboost_regex-mt.so

/usr/bin/ld: warning: libicuuc.so.52, needed by /opt/boost-1.54.0/lib/libboost_regex.so, not found (try using -rpath or -rpath-link) 

我知道,我要在的CMakeLists.txt文件中添加了一句:

set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} -rpath=/opt/icu_52.1/") 

,但它不工作:

c++: error: unrecognized command line option ‘-rpath=/opt/icu_52.1/’ 

當我嘗試:set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} -Wl,-rpath=/opt/icu_52.1/")

錯誤:/usr/bin/ld: warning: libicuuc.so.52, needed by /opt/boost-1.54.0/lib/libboost_regex-mt.so, not found (try using -rpath or -rpath-link)


Install.sh

module load icu-52.1 
module load boost_1_54_0 
module load qt5.5.0 

ENTLK_DIST=/home/hani/ENTLK_DIST 

export BOOST_ROOT=/opt/boost-1.54.0/ 
export ICU_ROOT=/opt/icu_52.1/ 

export PATH=/opt/qt-5.5.0/bin:$PATH 
export LD_LIBRARY_PATH=/opt/qt-5.5.0/lib 


####################################### 
# compile and install in ENTLK_DIST 
####################################### 
export ENTLK_DIST=/home/hani/ENTLK_DIST 

mkdir -p build && cd build 
rm -f CMakeCache.txt 
cmake .. -DCMAKE_INSTALL_PREFIX=$ENTLK_DIST 
make -j8 && make install 

的CMakeLists.txt

project(Entlk) 
cmake_minimum_required(VERSION 2.6)------------------------------------------------------------------------------ 
# Support C++11 
# ------------------------------------------------------------------------------ 
include(CheckCXXCompilerFlag) 
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STDCPP11) 
if (HAVE_STDCPP11) 
    message("-- C++11 supported") 
    add_definitions(-DHAVE_STDCPP11) # to be used in the cpp code 
    set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} -lboost_regex") 
else (HAVE_STDCPP11) 
    message("-- C++11 NOT supported") 
    set(CMAKE_CXX_FLAGS "-DNO_STDCPP11 ${CMAKE_CXX_FLAGS}") 
endif (HAVE_STDCPP11) 

# warnings 
# disable warnings on unknown pragmas (used by sqlite_modern) 
set(CMAKE_CXX_FLAGS "-W -Wall -Wno-unknown-pragmas ${CMAKE_CXX_FLAGS}") 

set(CMAKE_CXX_FLAGS "-fPIC ${CMAKE_CXX_FLAGS}") 

#use Stanford NER instead of MITIE 
#set(CMAKE_CXX_FLAGS "-DUSE_STANFORD_NER ${CMAKE_CXX_FLAGS}") 

# display install directory 
message(STATUS "Install directory is CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") 

# ------------------------------------------------------------------------------ 
# configure third party librairies 
# ------------------------------------------------------------------------------ 
include(cmake/EntlkUtils.cmake) 

# Path to look for FindXXX.cmake files 
set(CMAKE_MODULE_PATH 
    "${CMAKE_SOURCE_DIR}/cmake" # available in this project 
) 

find_package(ICU 4.4 REQUIRED) 
include_directories(${ICU_INCLUDE_DIRS}) 


# include Qt (for lima) 
include(${CMAKE_SOURCE_DIR}/cmake/manageQt5.cmake) 
addQt5Modules(Core Xml) 
include_directories(${Qt5_INCLUDES}) 
set(QT_LIBRARIES "${Qt5_LIBRARIES}") 


find_package(Boost 1.46 REQUIRED COMPONENTS regex serialization system filesystem program_options timer log) 
include_directories(${Boost_INCLUDE_DIR}) 
link_directories(${Boost_LIBRARY_DIRS}) 
# add define needed by Boost Log 
set(CMAKE_CXX_FLAGS "-DBOOST_LOG_DYN_LINK ${CMAKE_CXX_FLAGS}") 
#message(STATUS "using Boost libraries ${Boost_LIBRARIES}") 
+0

@Antonio我相信我必須在那裏添加一些東西。但是我忘記了正確的命令 –

+1

嘗試:'set(CMAKE_CXX_FLAGS「-std = C++ 11 $ {CMAKE_CXX_FLAGS} -Wl,-rpath =/opt/icu_52.1 /」)(注意附加的'-Wl, ')無論如何,在cmake中,你可以通過使用命令'link_directories'添加目錄來完成這個工作:似乎'libicuuc.so.52不在'Boost_LIBRARY_DIRS'路徑中。 – Antonio

+1

首先,找到你是否有'libicuuc.so.52',並找到它的位置 – Antonio

回答

1

添加到您的CMakeLists.txt文件:

link_directories(/opt/icu_52.1/lib) 

您也可以嘗試看看是否有人寫了一個查找包ICU,反正它不是標準的cmake模塊之間。

+0

@Antonios與-Wl,-rpath =/opt/icu_52.1 /「相同@ –

+1

@HaniGoc最好,您離開添加正確的工作flags to cmake。你不應該把'rpath'標誌和cmake命令混合在一起。 – Antonio