2015-04-05 59 views
14

我使用聯機安裝程序(在Ubuntu 14上運行)安裝了Qt5.4。我試圖編譯我的C++源代碼,並連接libQt5Core但LD引發錯誤:與libQt5Core的聯繫

make 
g++ -Wall test.o Party.o Communication.o FileParser.o PeerConnection.o ServerModule.o Utilities.o -o party -g -L/home/bush/Qt/5.4/gcc_64/lib -L/usr/lib/x86_64-linux-gnu/ -lQt5Core -lboost_system -lpthread 
/usr/bin/ld: warning: libicui18n.so.53, needed by /home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so, not found (try using -rpath or -rpath-link) 
/usr/bin/ld: warning: libicuuc.so.53, needed by /home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so, not found (try using -rpath or -rpath-link) 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_setMillis_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_fromUnicode_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_get_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_inDaylightTime_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_open_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_countAvailable_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_countAliases_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `u_errorName_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_openCountryTimeZones_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `u_strToUpper_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_getDefaultName_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `uenum_next_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucol_strcoll_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_getMaxCharSize_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_getAvailableName_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucol_open_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_getTimeZoneDisplayName_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_toUnicode_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `uenum_close_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucol_getSortKey_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_getAlias_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_close_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucol_setAttribute_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_close_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_openTimeZoneIDEnumeration_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_openTimeZones_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_getStandardName_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucol_close_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_compareNames_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_clone_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `u_strToLower_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_getDefaultTimeZone_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_open_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucnv_setSubstChars_53' 
/home/bush/Qt/5.4/gcc_64/lib/libQt5Core.so: undefined reference to `ucal_getDSTSavings_53' 
collect2: error: ld returned 1 exit status 
make: *** [party] Error 1 

我的Makefile:

CPPFLAGS=-g -c --std=c++0x -I/usr/include -I/home/bush/Qt/5.4/gcc_64/include -I/home/bush/Qt/5.4/gcc_64/include/QtCore -I/usr/include/boost 
LDFLAGS=-g -L/home/bush/Qt/5.4/gcc_64/lib -L/usr/lib/x86_64-linux-gnu/ -lQt5Core -lboost_system -lpthread 

all:party 

party:test.o Party.o Communication.o FileParser.o PeerConnection.o ServerModule.o Utilities.o 
    g++ -Wall $^ -o party $(LDFLAGS) 

test.o:test.cpp 
    g++ $(CPPFLAGS) test.cpp 
Party.o:Party.cpp 
    g++ $(CPPFLAGS) Party.cpp 
Communication.o:Communication.cpp 
    g++ $(CPPFLAGS) Communication.cpp 
FileParser.o:FileParser.cpp 
    g++ -fPIC $(CPPFLAGS) FileParser.cpp 
PeerConnection.o:PeerConnection.cpp 
    g++ $(CPPFLAGS) PeerConnection.cpp 
ServerModule.o:ServerModule.cpp 
    g++ $(CPPFLAGS) ServerModule.cpp 
Utilities.o:Utilities.cpp 
    g++ $(CPPFLAGS) Utilities.cpp 
+0

OS找不到ICU V53庫(QT是針對該版本的鏈接),檢查''中的/ usr/lib64' – gengisdave 2015-04-05 09:23:49

+0

沒有這樣的庫libicui18n' .. – Bush 2015-04-05 09:25:41

+0

可以解決安裝它,或者如果你有一個不同版本的ICU,僞造它與一個符號鏈接 – gengisdave 2015-04-05 10:16:47

回答

-1

嘗試添加-licuuc到生成文件的LDFLAGS。

sudo apt-get install libicu-dev
3

在我做了3個符號鏈接後,它工作。該lib已安裝,但我有一個比預期的更新的版本(55)(54)。

sudo ln -s /usr/local/Qt/5.5/gcc_64/lib/libicui18n.so.54 /usr/lib/x86_64-linux-gnu/libicui18n.so.54 
sudo ln -s /usr/local/Qt/5.5/gcc_64/lib/libicuuc.so.54 /usr/lib/x86_64-linux-gnu/libicuuc.so.54 
sudo ln -s /usr/local/Qt/5.5/gcc_64/lib/libicudata.so.54 /usr/lib/x86_64-linux-gnu/libicudata.so.54 
0

我在Ubuntu試圖構建Iris時出現此錯誤。 我解決了它通過刪除 CONFIG + =靜態 從.pro文件

11

我遇到了同樣的問題。但我只是通過這段代碼找到了出路。

export LD_LIBRARY_PATH=/usr/local/Qt/5.5/gcc_64/lib:$LD_LIBRARY_PATH 
+1

或任何你已經安裝Qt的路徑......但是,是的,這是有效的,是正確的答案。 – 2017-03-01 15:20:19

+1

是的,這是正確的答案,但如前所述使用您的特定安裝路徑。我發現運行「ldd libQt5Core.so。5「在正確的目錄中失敗,除非LD_LIBRARY_PATH設置正確。我認爲發生了什麼事(當然對我來說)是當主可執行文件被構建時,elf的庫運行路徑被設置爲正確的位置,所以libQt5Core被發現沒問題。 libQt5Core依次嘗試查找上面的SO,因爲它沒有運行路徑,也沒有LD_LIBRARY_PATH – mark 2017-06-28 13:48:19

3

我得到這樣的錯誤,當我試圖建立從QtCreator我在Debian項目8(從官方倉庫libicu52)。 我通過將我的Qt Kit(5.8.0)的'Environment'更改爲:LD_LIBRARY_PATH =/opt/Qt/5.8/gcc_64/lib:$ {LD_LIBRARY_PATH}來解決此問題。

Screenshot: Changes marked by red line