我創建了一個使用libmcrypt的C程序。我編譯它在CentOS的機器很多次,但現在,試圖做在Ubuntu同樣的事情,我得到這個:無法在Ubuntu上使用libmcrypt編譯程序
/tmp/ccM2ugbq.o: In function `encrypt':
util.c:(.text+0xa1): undefined reference to `mcrypt_module_open'
util.c:(.text+0xc6): undefined reference to `mcrypt_enc_get_iv_size'
util.c:(.text+0x134): undefined reference to `mcrypt_generic_init'
util.c:(.text+0x1dc): undefined reference to `mcrypt_generic'
util.c:(.text+0x1fa): undefined reference to `mcrypt_module_close'
/tmp/ccM2ugbq.o: In function `decrypt':
util.c:(.text+0x288): undefined reference to `mcrypt_module_open'
util.c:(.text+0x296): undefined reference to `mcrypt_enc_get_iv_size'
util.c:(.text+0x304): undefined reference to `mcrypt_generic_init'
util.c:(.text+0x375): undefined reference to `mdecrypt_generic'
util.c:(.text+0x380): undefined reference to `mcrypt_module_close'
,雖然我已經安裝了libmcrypt並妥善當編譯spacified標誌(-I/usr/include目錄-L/usr/lib目錄-lmcrypt)
任何人都可以指導我如何使用libmcrypt正確獲得編制工作?
編輯:手冊頁說:編譯爲根據您的安裝 「CC prog.c中-lmcrypt」,或 「抄送prog.c中-lmcrypt -lltdl」。 我也安裝了libltdl-dev,但它不起作用。
編輯1: 系統信息: 版本(運行uname -r
):
3.5.0-25泛型
釋放(運行lsb_release -a
):
沒有LSB模塊可用。
分銷商ID:Ubuntu的
描述:Ubuntu的12.10
推出:12.10
代號:量子
編輯2:
由於@teppic請求我顯示編譯命令,我解決了我的問題,但我需要一些解釋。婁我將詳細介紹的題目是:
,我曾經和失敗的命令:
CC -Wall -I ../路徑/到/包括-lmcrypt ./a_file.c ./some/ other/file.c ./some/other/files.c ./main/file.c -I/some/include/path -lother_lib -o ./bin/out
之後,我只把-lmcrypt
在命令結束並從第一個地方刪除它,它的工作。 在我最初的問題中,我告訴過你我之前在CentOS中編譯過它,一切正常。這是真的,即使在CentOS中編譯命令是前者(可能某些文件的順序或某些庫不同)。
任何人都可以解釋我如何標誌順序影響編譯成功或失敗?
你安裝了'libmcrypt-dev'嗎? – 2013-03-12 07:06:00
@WillPalmer是的,我還安裝了* libltdl-dev *幷包含它,但行爲相同。 – artaxerxe 2013-03-12 07:20:25
你能給出確切的操作系統信息? – acarlow 2013-03-12 07:21:55