1
我正在從Ubuntu 10.04遷移到Ubuntu 11.10(oneiric),但是當我嘗試編譯一些可以在Ubuntu 10.04上正常工作的應用程序時,我遇到了問題。Ubuntu上的GCC上的鏈接問題11
我安裝了sqlite3和unac庫,這與我在Ubuntu 10.4上使用的庫相同。我已經使用如下命令安裝:
sudo su
apt-get install libunac1-dev
apt-get install sqlite3
apt-get install libsqlite3-dev
但磨片我運行:GCC -Wall -lsqlite3 -lunac -Werror -02 -o ILD.out ILD.c
我收到以下錯誤:
/tmp/cceRDsMZ.o: In function `removediacritics':
ILD.c:(.text+0x1ae): undefined reference to `unac_string'
/tmp/cceRDsMZ.o: In function `main':
ILD.c:(.text.startup+0x1a): undefined reference to `sqlite3_open'
ILD.c:(.text.startup+0x6c): undefined reference to `sqlite3_prepare_v2'
ILD.c:(.text.startup+0x80): undefined reference to `sqlite3_step'
ILD.c:(.text.startup+0x98): undefined reference to `sqlite3_column_text'
ILD.c:(.text.startup+0xb0): undefined reference to `sqlite3_step'
ILD.c:(.text.startup+0xc1): undefined reference to `sqlite3_finalize'
ILD.c:(.text.startup+0xcd): undefined reference to `sqlite3_close'
ILD.c:(.text.startup+0x10c): undefined reference to `sqlite3_close'
ILD.c:(.text.startup+0x120): undefined reference to `sqlite3_errmsg'
ILD.c:(.text.startup+0x144): undefined reference to `sqlite3_close'
collect2: ld returned 1 exit status
我的GCC版本:gcc 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
我不知道如何解決這個問題。任何幫助非常感謝。提前致謝。
檢查庫的安裝位置並將路徑傳遞給編譯器。例如'-L'選項。 – 2012-03-18 18:08:32
嘗試將庫移動到命令末尾('gcc -Wall -Werror -O2 -o ILD.out ILD.c -lsqlite3 -lunac') – asaelr 2012-03-18 18:57:49
另外,unac和sqlite3都使用pkgconfig。你爲什麼不在編譯期間使用'$(pkg-config --cflags sqlite3)$(pkg-config --cflags unac)'和'$(pkg-config --libs sqlite3)$(pkg-config --libs unac)'在鏈接過程中(或讓autotools解決所有問題)? – ephemient 2012-03-18 21:58:03