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

时间:2016-04-20 12:30:15

标签: c++ boost cmake icu

简介

我想编译一个使用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}")

1 个答案:

答案 0 :(得分:1)

添加到您的CMakeLists.txt文件:

link_directories(/opt/icu_52.1/lib)

您还可以尝试查看是否有人为ICU编写了查找包,无论如何它不属于标准的cmake模块。