所以,我在编译使用boost 1.50.0库的项目时遇到了麻烦,更具体地说,是boost 'locale'库。当我编译时,我收到这个错误:
(.text._ZN5boost6locale8impl_icu10num_formatIcED2Ev[_ZN5boost6locale8impl_icu10num_formatIcED5Ev]+0x20):-1: error: undefined reference to `icu_48::Locale::~Locale()'
我的直接假设是我没有正确地在项目中链接libicu-dev库,并将库添加到我的cmake文件(FindICU.cmake)。
FindICU.cmake:
# Try to find the ICU library
# ICU_FOUND - system has ICU
# ICU_INCLUDE_DIR - the ICU include directory
# ICU_LIBRARY - the ICU library
FIND_PATH(ICU_INCLUDE_DIR NAMES utf8.h utypes.h PATH_SUFFIXES unicode)
SET(_ICUI18N_STATIC_LIBS libicui18n.a)
SET(_ICUI18N_SHARED_LIBS libicui18n.dll.a icui18n)
SET(_ICUUC_STATIC_LIBS libicuuc.a)
SET(_ICUUC_SHARED_LIBS libicuuc.dll.a icuuc)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(ICUI18N_LIBRARY NAMES ${_ICUI18N_STATIC_LIBS} ${_ICUI18N_SHARED_LIBS})
FIND_LIBRARY(ICUUC_LIBRARY NAMES ${_ICUUC_STATIC_LIBS} ${_ICUUC_SHARED_LIBS})
ELSE()
FIND_LIBRARY(ICUI18N_LIBRARY NAMES ${_ICUI18N_SHARED_LIBS} ${_ICUI18N_STATIC_LIBS})
FIND_LIBRARY(ICUUC_LIBRARY NAMES ${_ICUUC_SHARED_LIBS} ${_ICUUC_STATIC_LIBS})
ENDIF()
SET(ICU_LIBRARIES ${ICUI18N_LIBRARY} ${ICUUC_LIBRARY})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ICU DEFAULT_MSG ICU_LIBRARIES ICU_INCLUDE_DIR)
MARK_AS_ADVANCED(ICU_LIBRARIES ICU_INCLUDE_DIR)
,并使我的项目搜索boost库在这里,像这样:
# find boost
set(REQUIRED_BOOST_COMPONENTS locale system filesystem regex thread)
if(WIN32)
set(Boost_THREADAPI win32)
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DBOOST_THREAD_USE_LIB) # fix boost thread linkage
set(REQUIRED_BOOST_COMPONENTS ${REQUIRED_BOOST_COMPONENTS} chrono) # mingw32 does not have std::thread
else()
find_package(ICU)
set(Boost_LIBRARIES ${Boost_LIBRARIES} ${ICU_LIBRARIES})
endif()
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_LIBS ${USE_STATIC_LIBS})
find_package(Boost 1.50.0 COMPONENTS ${REQUIRED_BOOST_COMPONENTS} REQUIRED)
它发现没有问题
-- Found ICU: /usr/lib/libicui18n.a;/usr/lib/libicuuc.a
-- Boost version: 1.50.0
-- Found the following Boost libraries:
-- locale
-- system
-- filesystem
-- regex
-- thread
但是当我尝试编译时,我仍然得到这个错误。我正在运行Ubuntu 12.04,从https://launchpad.net/~28msec/+archive/boost仓库获得我的boost库,因为12.04确实提供了一个boost 1.50库的包。我使用libicu-dev (4.6.x)的标准包。
编辑:我还编译了我自己的1.50.0 boost库配置有和没有ICU(两者都没有工作),我还编译了我自己的ICU库和仍然相同的错误…我完全被这个难住了。
也许有人能帮我弄清楚发生了什么事。任何帮助都是感激的!谢谢,本。
版本号(在链接中使用)由ICU头设置,因此似乎您正在编译4.8,但试图链接到其他东西(如4.6)。Uvernum.h(或在旧版本中,Uvernum.h)包含版本号。