【发布时间】:2015-11-29 09:35:39
【问题描述】:
在将我的代码与 libmagic 链接时,我正在努力解决这个问题:
test.c:(.text+0x16): undefined reference to `magic_open'
test.c:(.text+0x50): undefined reference to `magic_load'
test.c:(.text+0x60): undefined reference to `magic_error'
test.c:(.text+0x84): undefined reference to `magic_close'
test.c:(.text+0x9e): undefined reference to `magic_file'
test.c:(.text+0xba): undefined reference to `magic_close'
collect2: ld returned 1 exit status
但是,仅当 gcc 版本 > 4.4 时才会出现此问题。要编译,我使用以下命令:
gcc -L/usr/lib/ -lmagic test.c -o test
可以在here 找到使用 libmagic 的示例代码。我已经检查过了,这个问题也出现了。显然 libmagic 和 libmagic-dev 安装在我的系统上(Ubuntu 14.04)。
除了降级 gcc 版本之外,有什么方法可以处理这个问题?
【问题讨论】:
-
我投了反对票,因为您的问题没有显示足够的研究。通过网络搜索,您将获得无数答案。