我的sbuf(9)怎么了?
这是我的程序:
#include <sys/types.h>
#include <sys/sbuf.h>
#include <unistd.h>
int main() {
struct sbuf * sb;
sb = sbuf_new_auto();
return 0;
}
当我用
clang -v test.c
编译程序时,我得到:FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: i386-unknown-freebsd10.3
Thread model: posix
Selected GCC installation:
"/usr/bin/clang" -cc1 -triple i386-unknown-freebsd10.3 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu i486 -v -resource-dir /usr/bin/../lib/clang/3.4.1 -fdebug-compilation-dir /usr/home/0mp/g/freebsd/contrib/openbsm/bin/bsmconv -ferror-limit 19 -fmessage-length 170 -mstackrealign -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /tmp/test-fc3a72.o -x c test.c
clang -cc1 version 3.4.1 based upon LLVM 3.4.1 default target i386-unknown-freebsd10.3
ignoring nonexistent directory "/usr/bin/../lib/clang/3.4.1/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/clang/3.4.1
/usr/include
End of search list.
"/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -m elf_i386_fbsd -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/test-fc3a72.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
/tmp/test-fc3a72.o: In function `main':
test.c:(.text+0x3d): undefined reference to `sbuf_new'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
笔记
编译器还会向我显示sbuf函数的错误和警告,因此它知道
sys/sbuf.h
的外观。我使用FreeBSD 10.3 RELEASE i386。
最佳答案
在编译命令中尝试使用-lsbuf吗?
关于c - 在FreeBSD上未定义对sbuf函数的引用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38022644/