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