Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linking error: undefined reference to icu_50::UnicodeString::UnicodeString()

I am trying to compile my project where I've declared as class members some:

icu::UnicodeString label;
icu::UnicodeString tags;
icu::UnicodeString domain;
icu::UnicodeString data;

After having included (yes it is found)

#include <unicode/unistr.h>

In my CMakeLists.txt it searches, finds and links with: icuuc icudata (libicuuc, libicudata) as the output suggests prior to throwing the errors:

-o icarus -rdynamic -lPocoNet -lPocoUtil -lPocoXML -licuuc -licudata

I have built and installed from source icu4c 50.1.2, and installed it under /usr/local/* cmake finds the libraries properly, as my errors are from the linking phase:

undefined reference to icu_50::UnicodeString::UnicodeString()' undefined reference toicu_50::UnicodeString::~UnicodeString()'

I am using gcc-4.7.2 with -std=c++0x enabled on Debian Wheezy. The exact same code did compile with gcc-4.3.2 with the same flags on Debian Squeeze last night!

I cannot for the life of me, figure out what I am doing wrong! Please help!

like image 786
Ælex Avatar asked Feb 14 '13 12:02

Ælex


1 Answers

It appears this was my fault when building ICU4C. I am leaving a brief explanation as I have seen many google posts on this but no answers. If you read carefully the documentation when configuring icu, it states that you should do certain things:

1) Define using namespace to false:

 #   ifndef U_USING_ICU_NAMESPACE
-#       define U_USING_ICU_NAMESPACE 1
+        // Set to 0 to force namespace declarations in ICU usage.
+#       define U_USING_ICU_NAMESPACE 0

2) When building on linux, I went for a non-shared, static library:

runConfigureICU Linux --enable-static --disable-shared

3) This is the important part that caused my errors:

By default, ICU library entry point names have an ICU version suffix. Turn this off for a system-level installation, to enable upgrading ICU without breaking applications. For example:

runConfigureICU Linux --disable-renaming

The public header files from this configuration must be installed for applications to include and get the correct entry point names.

I did do that on Squeeze, but not on Wheezy, thus causing all the linkage errors on a system-wide installation. Lesson learned, hope it helps someone else.

like image 174
Ælex Avatar answered Oct 27 '22 17:10

Ælex