我想编写简单的 C 程序来为 Linux 上的一个特定文件设置 ACL。我的起始代码试图使用“acl.h”中的函数。我正在使用 Ubuntu 13.10,我已经安装了“访问控制列表实用程序”-“acl 2.2.52-1”。这是我的代码:
#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
我该如何解决这个错误?
最佳答案
您链接到的库需要放在最后
gcc myAcl.c -lacl
关于c - 使用 acl.h - 对 `acl_init' 错误的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19666050/