référence indéfinie à `icu_56 :: UnicodeSsortingng :: UnicodeSsortingng (char signé, unsigned short const *, int) ‘

Je cours Ubuntu et je peux construire l’ICU

J’ai inclus:

#include  using namespace icu; 

Ceci est ma méthode de construction pour ICU:

 CPPFLAGS="-DU_USING_ICU_NAMESPACE=0" CPPFLAGS="-DU_CHARSET_IS_UTF8=1" export CFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_GNUC_UTF16_STRING=1 -DU_STATIC_IMPLEMENTATION" export CXXFLAGS="-DU_USING_ICU_NAMESPACE=0 -std=gnu++0x -DU_CHARSET_IS_UTF8=1 -DU_GNUC_UTF16_STRING=1 -DU_HAVE_CHAR16_T=1 -DUCHAR_TYPE=char16_t -Wall --std=c++0x -DU_STATIC_IMPLEMENTATION" export CPPFLAGS="-DU_USING_ICU_NAMESPACE=0 -DU_CHARSET_IS_UTF8=1 -DU_STATIC_IMPLEMENTATION" export LDFLAGS="-std=gnu++0x" ./runConfigureICU Linux --enable-static --disable-shared --disable-renaming make check sudo make install 

Je relie ensuite à

 /usr/local/lib/libicuuc.a 

et essayer de comstackr

 icu::UnicodeSsortingng s1=UNICODE_STRING("such characters are safe 123 %-.", 32); 

mais obtenez l’erreur

 undefined reference to `icu_56::UnicodeSsortingng::UnicodeSsortingng(signed char, unsigned short const*, int)' 

J’ai trouvé un autre article ici sur SO concernant le même problème, mais quand je suis les étapes fournies, il ne résout pas mon problème et peut être une version différente.

EDIT: Ceci est la sortie de l’EDI lors de la construction du projet

 Cleaning Solution: myProject (Debug) Cleaning: myProject (Debug) Removing output files... Clean complete Building Solution: myProject (Debug) Building: myProject (Debug) Performing main compilation... Precompiling headers Compiling source to object files g++ -MMD "/home/user/myProject/myProject/main.cpp" -g -O0 -std=c++11 -DDEBUG -I"/home/user/myProject/myProject/include" -I"/home/user/myProject/icu/unicode" -I"/home/user/myProject/myProject/.prec/Debug" -c -o "/home/user/myProject/myProject/bin/Debug/main.o" Generating binary "myProject" from object files g++ -o "/home/user/myProject/myProject/bin/Debug/myProject" "/home/user/myProject/myProject/bin/Debug/main.o" "/home/user/myProject/icu/libicuuc.a" /home/user/myProject/myProject/bin/Debug/main.o: In function `icuTest': /home/user/myProject/myProject/icuTest.hpp:3: undefined reference to `icu_56::SsortingngPiece::SsortingngPiece(char const*)' /home/user/myProject/myProject/icuTest.hpp:3: undefined reference to `icu_56::UnicodeSsortingng::fromUTF8(icu_56::SsortingngPiece const&)' /home/user/myProject/myProject/icuTest.hpp:3: undefined reference to `icu_56::UnicodeSsortingng::~UnicodeSsortingng()' /home/user/myProject/myProject/icuTest.hpp:3: undefined reference to `icu_56::UnicodeSsortingng::~UnicodeSsortingng()' collect2: error: ld returned 1 exit status Build complete -- 4 errors, 0 warnings ---------------------- Done ---------------------- Build: 4 errors, 0 warnings 

Je remarque que votre ligne g ++ ne pointe pas vers /usr/local/lib/libicuuc.a où vous dites avoir installé icu. Il est évidemment compilé avec les en-têtes OK, mais la bibliothèque statique existe-t-elle dans le chemin que vous utilisez (“/home/user/myProject/icu/libicuuc.a”)?

Quand vous avez couru:

 ./runConfigureICU Linux --enable-static --disable-shared --disable-renaming 

avez-vous tenu compte de l’avertissement?

 *** WARNING: You must set the following flags before code comstackd against this ICU will function properly: -DU_DISABLE_RENAMING=1 The recommended way to do this is to prepend the following lines to source/common/unicode/uconfig.h or #include them near the top of that file. /* -DU_DISABLE_RENAMING=1 */ #define U_DISABLE_RENAMING 1 

Sinon, faites-le maintenant.

Ensuite, modifiez votre programme de test en #include avant toute autre chose, par exemple

main.cpp

 #include  #include  #include  int main() { icu::UnicodeSsortingng s1=UNICODE_STRING("such characters are safe 123 %-.", 32); (void)s1; return 0; } 

Le comstackra et liera contre libicuuc.a .

Vous pouvez, si vous le souhaitez, vous assurer que les en-têtes unicode/uconfig.h tels que unicode/uconfig.h et unicode/platform.h sont automatiquement inclus par le compilateur avant toute utilisation en utilisant un en-tête de pré-inclusion, par exemple

icu_preinc.h

 // pre-include header for icu #include  #include  

que vous passez à GCC ou clang avec l’option:

 -include /path/to/icu_preinc.h 

Vous pouvez mettre cette option dans votre CPPFLAGS si vous utilisez un système de génération basé sur la make .

Dans le cas du programme jouet ci-dessus, il suffit de définir U_DISABLE_RENAMING=1 sur la ligne de commande, sans inclure

 g++ -DU_DISABLE_RENAMING=1 -o prog main.cpp -L/your/libicuuc/search/path -licuuc 

Je pense que le problème réside dans la syntaxe g ++:

 g++ -o "/home/user/myProject/myProject/bin/Debug/myProject" "/home/user/myProject/myProject/bin/Debug/main.o" "/home/user/myProject/icu/libicuuc.a" 

Vous dites construire myProject en utilisant le fichier object main.o et le fichier object libicuuc.a. Cependant, ce dernier n’est pas un fichier object, c’est une bibliothèque statique. Je pense que vous devriez modifier la ligne g ++ pour:

 g++ /home/user/myProject/myProject/bin/Debug/main.o -L/home/user/myProject/icu/ -licuuc -o /home/user/myProject/myProject/bin/Debug/myProject 

-L/home/user/myProject/icu/ dire à l’éditeur de liens de rechercher des bibliothèques dans / home / user / myProject / icu / folder et -licuuc dit de lier une bibliothèque nommée libicuuc.a ou libicuuc.so