4

首先我在 Ubuntu 12.04 上安装 sctp
sudo apt-get install libsctp-dev lksctp-tools
然后在我的 .c 文件中,我包括:

#include < netinet/in.h >
#include < netinet/sctp.h >
#include < sys/socket.h >
#include < stdlib.h >
#include < unistd.h >

但是,当我用 gcc 编译时,结果是:

 undefined reference to `sctp_recvmsg'
 undefined reference to `sctp_get_no_strms'
 undefined reference to `sctp_sendmsg'

怎么了?

4

1 回答 1

6

如果你真的编译,gcc temp.c -o temp那么你没有链接任何库(除了默认libc.6.so),你需要一些额外的参数gcc; 也许尝试编译

 gcc -Wall -g temp.c -lsctp -o temp

一旦您的程序在调试器的帮助下被gdb调试并且您认为它没有错误,您可以要求编译器使用

 gcc -Wall -O2 temp.c -lsctp -o temp

程序参数的顺序gcc是重要且重要的。

于 2013-04-21T23:03:53.483 回答