为什么我没有在Linux中编译sctp程序?

为什么我没有在Linux中编译sctp程序?,linux,undefined-reference,sctp,Linux,Undefined Reference,Sctp,首先,我在Ubuntu 12.04上安装了sctp sudo apt get安装libsctp dev lksctp工具 然后在我的.c文件中,我包括: #include < netinet/in.h > #include < netinet/sctp.h > #include < sys/socket.h > #include < stdlib.h > #include < unistd.h > 有什么问题吗?如果您真的使用gcc

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

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

有什么问题吗?

如果您真的使用
gcc temp.c-o temp
进行编译,那么您没有链接任何库(除了默认的
libc.6.so
),您需要一些附加参数来
gcc
;也许试着用

 gcc -Wall -g temp.c -lsctp -o temp
<>你的程序在<代码> GDB < /代码>调试器的帮助下被调试,并且你认为它是无bug的,你可以请求编译器使用

优化它。
 gcc -Wall -O2 temp.c -lsctp -o temp

gcc
的程序参数顺序非常重要。

显示编译命令,这是源代码的一部分。显示用于编译程序的
gcc
命令。请记住,
gcc
的参数顺序非常重要。
 gcc -Wall -O2 temp.c -lsctp -o temp