QT編譯錯誤

2021-08-19 21:13:35 字數 1391 閱讀 2574

1. linux gcc編譯error:"collect2: ld returned 1 exit status"

2023年06月27日 14:03:33

在linux環境下編乙個工程,無論怎麼編譯總是出現錯誤,提示如下:

bmeta_info.cpp:4280: undefined reference to `crypt』

collect2: ld returned 1 exit status

網上查的資料表示:

undefined reference to 錯誤:這類錯誤是在連線過程中出現的,可能有兩種原因∶一是使用者自己定義的函式或者全域性變數所在源**檔案,沒有被編譯、連線,或者乾脆還沒有定義,這 需要使用者根據實際情況修改源程式,給出全域性變數或者函式的定義體;二是未定義的符號是乙個標準的庫函式,在源程式中使用了該庫函式,而連線過程中還沒有 給定相應的函式庫的名稱,或者是該檔案庫的目錄名稱有問題

使用 man crypt命令後從中找到如下資訊:

the glibc2 version

of this function has the following additional features. if salt is a character

string starting with

the three characters

"$1$" followed by

at most eight characters, and optionally terminated by

"$", then

instead of using the des machine, the glibc crypt function uses an md5-based algorithm, and outputs up to

34 bytes, namely "$1$$", where

"" stands for

the up to

8characters following "$1$"

inthe salt, followed by

22 bytes chosen from

theset [a–za–z0–9./]. the entire key is significant here (instead of only the

first

8 bytes).

programs using this function must be linked with -lcrypt.

最重要的是最後一句」programs using this function must be linked with -lcrypt.」,即鏈結需要加入-lctypt

解決方法:g++ -lcrypt ***x

【參考:

Qt 5 0 2 32 bit 編譯錯誤

23 28 02 為專案1執行步驟 23 28 02 無法啟動程序 d software qt 5.0.2 mingw47 32 bin qmake.exe c users lk documents 1 1.pro r spec win32 g config debug config declara...

Qt原物件metaObject編譯錯誤的問題

關於元物件編譯器的作用可參考文章 qt中moc的作用 編譯由元物件編譯器生成的 moc filename.cpp 檔案時,報錯 classname is not a class or namespace name錯誤定位於 void classname qt static metacall qobj...

mk編譯錯誤

要在工程 中加乙個巨集去控制 在config.mk中定義這個巨集 enable it6263 1 在compile option.mk中根據這個值來定義巨集 ifeq enable it6263 1 cc opts denable it6263 1 else cc opts denable it62...