2013-10-29 30 views
0

我想編寫簡單的C程序來將ACL設置爲Linux上的一個特定文件。我的開始代碼嘗試使用「acl.h」中的函數。我使用Ubuntu 13.10,我已經安裝了「訪問控制列表實用程序」 - 「acl 2.2.52-1」。這裏是我的代碼:使用acl.h - 對`acl_init'錯誤的未定義引用

#include <sys/acl.h> 
#include <stdio.h> 

int main() {  
acl_t aclvar; 
int count = 1; 
aclvar = acl_init(count); 
return 0; 
} 

的問題是,我得到錯誤,而與 「GCC myAcl.c」 或 「GCC -lacl myAcl.c」 編譯:

/tmp/cc5sVzSR.o: In function `main': 
myAcl.c:(.text+0x15): undefined reference to `acl_init' 
collect2: error: ld returned 1 exit status 

我該如何解決這個錯誤?

+0

來看看在通過第答案,並試圖瞭解的重要性和headerfile和圖書館之間的差異。 – hari

回答

2

您鏈接到所需的庫去年

gcc myAcl.c -lacl