compiling Boost boost_1_45_0 regex with icu (redhat).

Greetings. I am trying to compile boost regex with icu. The icu library is placed in a non-standard place, so I have set the appropriate environment variable. However everytime I run bjam, console output (amongst many thing) says - has_icu builds : no I have invoked bjam with -sBOOST_HAS_ICU=1. No luck picking icu. I have invoked bjam with -sICU_PATH=/home/xxx/yyy, and no luck either. OTOH, if I go to the subdirectory : libs/regex/build and do 'make -f gcc.mak' It builds with -DBOOST_HAVE_ICU=1 and with the right icu include directory in the compile line. I am new to compiling boost, and would love to find out what is going on. And how can I rectify it. Thanks, CD.

I am trying to compile boost regex with icu. The icu library is placed in a non-standard place, so I have set the appropriate environment variable.
However everytime I run bjam, console output (amongst many thing) says - has_icu builds : no
I have invoked bjam with -sBOOST_HAS_ICU=1. No luck picking icu. I have invoked bjam with -sICU_PATH=/home/xxx/yyy, and no luck either.
OTOH, if I go to the subdirectory : libs/regex/build and do 'make -f gcc.mak' It builds with -DBOOST_HAVE_ICU=1 and with the right icu include directory in the compile line.
I am new to compiling boost, and would love to find out what is going on. And how can I rectify it.
Take a look in boost-path/bin.v2/config.log and you'll see the actual error messages and the command lines used, which should give you a hint. You could also try: bjam include=path-to-icu-headers linkflags=extra-linker-flags-required HTH, John.

(I am listing a problem in compling boost/regex, and a solution, and want to know if this is the right approach. We are trying to use boost as a static library, with regex and icu support. Thanks. =cs) Here used is the vanilla static compile of ICU (i.e. no changes to icu4c-4_6-src.tgz), installed in subdirectory icu2 as: ./bootstrap.sh --with-icu=/home/cxs/icu2 --prefix=osboost --without-libraries=python link=static variant=release ==================================================================== $ ./bjam --list-libraries -d+2 .... .... gcc.compile.c++ bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu_test.o "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -pedantic -g -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_HAS_ICU=1 -I"." -I"/home/cxs/icu2/include" -c -o "bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu_test.o" "libs/regex/build/has_icu_test.cpp" libs/regex/build/has_icu_test.cpp:26:2: warning: no newline at end of file libs/regex/build/has_icu_test.cpp: In function 'int main()': libs/regex/build/has_icu_test.cpp:24: warning: unused variable 'c' gcc.link bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu "g++" -L"/home/cxs/icu2/lib" -Wl,-R -Wl,"/home/cxs/icu2/bin" -Wl,-R -Wl,"/home/cxs/icu2/lib" -Wl,-rpath-link -Wl,"/home/cxs/icu2/lib" -o "bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu" -Wl,--start-group "bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu_test.o" -Wl,-Bstatic -Wl,-Bdynamic -licuuc -licui18n -licudata -Wl,--end-group -g /home/cxs/icu2/lib/libicuuc.a(putil.ao): In function `uprv_dl_sym_46': putil.c:(.text+0x241): undefined reference to `dlsym' /home/cxs/icu2/lib/libicuuc.a(putil.ao): In function `uprv_dl_open_46': putil.c:(.text+0x2a6): undefined reference to `dlopen' /home/cxs/icu2/lib/libicuuc.a(putil.ao): In function `uprv_dl_close_46': putil.c:(.text+0x269): undefined reference to `dlclose' collect2: ld returned 1 exit status ...failed updating 1 target... Performing configuration checks - has_icu builds : no .... .... (So icu is not detected due to a missing -ldl flag in the last call to g++ above.) ==================================================================== This issue is taken care of by adding to libs/regex/build/Jamfile.v2 these lines to the else clause of if $(ICU_LINK) {...} else { lib dl : : <search>$(ICU_PATH)/lib <link>shared <runtime-link>shared ; lib dl : : <toolset>msvc <variant>debug <name>dl <search>$(ICU_PATH)/lib <link>shared <runtime-link>shared ; lib dl : : <name>this_is_an_invalid_library_name ; ... } and add to ICU_OPTS = <library>dl/<link>shared/<runtime-link>shared The question is: is this the correct approach? Thanks, =cs

Candid Shot wrote:
(I am listing a problem in compling boost/regex, and a solution, and want to know if this is the right approach. We are trying to use boost as a static library, with regex and icu support. Thanks. =cs)
Here used is the vanilla static compile of ICU (i.e. no changes to icu4c-4_6-src.tgz), installed in subdirectory icu2 as:
./bootstrap.sh --with-icu=/home/cxs/icu2 --prefix=osboost --without-libraries=python link=static variant=release
====================================================================
$ ./bjam --list-libraries -d+2
.... .... gcc.compile.c++ bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu_test.o
"g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -pedantic -g -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_HAS_ICU=1 -I"." -I"/home/cxs/icu2/include" -c -o "bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu_test.o" "libs/regex/build/has_icu_test.cpp"
libs/regex/build/has_icu_test.cpp:26:2: warning: no newline at end of file libs/regex/build/has_icu_test.cpp: In function 'int main()': libs/regex/build/has_icu_test.cpp:24: warning: unused variable 'c'
gcc.link bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu
"g++" -L"/home/cxs/icu2/lib" -Wl,-R -Wl,"/home/cxs/icu2/bin" -Wl,-R -Wl,"/home/cxs/icu2/lib" -Wl,-rpath-link -Wl,"/home/cxs/icu2/lib" -o "bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu" -Wl,--start-group "bin.v2/libs/regex/build/gcc-4.1.2/debug/has_icu_test.o" -Wl,-Bstatic -Wl,-Bdynamic -licuuc -licui18n -licudata -Wl,--end-group -g
/home/cxs/icu2/lib/libicuuc.a(putil.ao): In function `uprv_dl_sym_46': putil.c:(.text+0x241): undefined reference to `dlsym' /home/cxs/icu2/lib/libicuuc.a(putil.ao): In function `uprv_dl_open_46': putil.c:(.text+0x2a6): undefined reference to `dlopen' /home/cxs/icu2/lib/libicuuc.a(putil.ao): In function `uprv_dl_close_46': putil.c:(.text+0x269): undefined reference to `dlclose' collect2: ld returned 1 exit status ...failed updating 1 target... Performing configuration checks
- has_icu builds : no .... ....
(So icu is not detected due to a missing -ldl flag in the last call to g++ above.) ====================================================================
This issue is taken care of by adding to libs/regex/build/Jamfile.v2 these lines
to the else clause of
if $(ICU_LINK) {...} else {
lib dl : : <search>$(ICU_PATH)/lib <link>shared <runtime-link>shared ; lib dl : : <toolset>msvc <variant>debug <name>dl <search>$(ICU_PATH)/lib <link>shared <runtime-link>shared ; lib dl : : <name>this_is_an_invalid_library_name ; ... }
and add to ICU_OPTS = <library>dl/<link>shared/<runtime-link>shared
The question is: is this the correct approach? Thanks,
I think the ideal approach is to build shared ICU libraries. Alternatively, can you check whether ICU build you have appears to include .pc files and whether those .pc files mention dependency in 'dl'? - Volodya

The question is: is this the correct approach? Thanks,
No the problem is that the list of libraries that ICU needs to link against is platform specific - that code would certainly break on Windows for example where there is no dl.lib (and no dlopen function either). I could add -ldl to the command line on specific platforms I guess - Linux anyway - but ultimately I think this may best be solved by the user adding linkflags=-ldl to the command line. HTH, John.

I think this may best be solved by the user adding linkflags=-ldl to the command line.
Thanks, John. That worked for me. I am curious, why is the file icu-i18n.pc file (shown below) not yielding the -ldl flag. Is there a way to debug this. I am new to this. Thanks. =CS ---------------------------- /home/cxs/icu2/lib/pkgconfig/icu-i18n.pc -------------> # Copyright (C) 2010, International Business Machines Corporation. All Rights Reserved. prefix = /home/lwalia/icu2 exec_prefix = ${prefix} #bindir = ${exec_prefix}/bin libdir = ${exec_prefix}/lib includedir = ${prefix}/include baselibs = -lpthread -ldl -lm #datarootdir = ${prefix}/share #datadir = ${datarootdir} #sbindir = ${exec_prefix}/sbin #mandir = ${datarootdir}/man #sysconfdir = ${prefix}/etc CFLAGS = -O3 -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long $(THREADSCFLAGS) #CXXFLAGS = -O3 -W -Wall -ansi -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long $(THREADSCXXFLAGS) DEFS = -DHAVE_CONFIG_H UNICODE_VERSION=6.0 ICUPREFIX=icu ICULIBSUFFIX= LIBICU=lib${ICUPREFIX} #SHAREDLIBCFLAGS=-fPIC pkglibdir=${libdir}/icu${ICULIBSUFFIX}/4.6 #pkgdatadir=${datadir}/icu${ICULIBSUFFIX}/4.6 ICUDATA_NAME = icudt46l #ICUPKGDATA_DIR=${exec_prefix}/lib #ICUDATA_DIR=${pkgdatadir} ICUDESC=International Components for Unicode Version: 4.6 Cflags: -I${includedir} # end of icu.pc.in Description: International Components for Unicode: Internationalization library Name: icu-i18n Requires: icu-uc Libs: -licui18n ----- Original Message ---- From: John Maddock <boost.regex@virgin.net> To: boost@lists.boost.org Sent: Tue, January 4, 2011 9:32:32 AM Subject: Re: [boost] compiling Boost boost_1_45_0 regex with icu (redhat). Aproblem and its fix.

I think this may best be solved by the user adding linkflags=-ldl to the command line.
Thanks, John. That worked for me.
I am curious, why is the file icu-i18n.pc file (shown below) not yielding the -ldl flag. Is there a way to debug this. I am new to this.
Not sure I follow - that file will be used when you build ICU, but not by Boost.Build when you build regex, so all you can really do in that case is use it as a reference to see what libs are required by an ICU static lib. Of course if you use ICU as a shared lib then none of this is relevant since the .so is already linked against all it needs. John.
participants (3)
-
Candid Shot
-
John Maddock
-
Vladimir Prus