So, I am having trouble compiling my project that is using boost 1.50.0 libraries, more specifically the boost ‘locale’ library. I am receiving this error when I compile:
(.text._ZN5boost6locale8impl_icu10num_formatIcED2Ev[_ZN5boost6locale8impl_icu10num_formatIcED5Ev]+0x20):-1: error: undefined reference to `icu_48::Locale::~Locale()'
My immediate assumption was that I was not linking the libicu-dev libraries in the project correctly, and added the library to my cmake files (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)
and made my project search for the boost libs here like this:
# 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)
and it finds it no problem
-- 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
But I am still getting this error when I try to compile. I am running Ubuntu 12.04 getting my boost libraries from https://launchpad.net/~28msec/+archive/boost repository as 12.04 does offer a package for boost 1.50 libraries. I am using standard package for libicu-dev (4.6.x).
EDIT: I also compiled my own 1.50.0 boost libs configured with and without ICU (both didn’t work) I also compiled my own ICU libs and still same error… I’m completely stumped on this.
Perhaps someone will be able to help me figure out what is going on. Any help is appreciated! Thanks, Ben.
The version number (used in the linkage) is set by the ICU headers, so it seems you are compiling against 4.8 but trying to link against something else (such as 4.6). uvernum.h (or in older versions, uversion.h) contains the version #.