libicuuc.so.52,需要 libboost_regex-mt.so

libicuuc.so.52, needed libboost_regex-mt.so

简介

我想编译一个使用 ICU 和 libboost 的代码。为此,我使用以下 install.sh 文件。问题是我收到此错误:

/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}")

添加到您的 CMakeLists.txt 文件:

link_directories(/opt/icu_52.1/lib)

你也可以看看有没有人写过ICU的find包,反正cmake的标准模块里没有。