4

First I install sctp on Ubuntu 12.04
sudo apt-get install libsctp-dev lksctp-tools
Then in my .c file,I include :

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

howerver,when I compiled with gcc,the result is:

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

What is wrong?

ollo
  • 24,797
  • 14
  • 106
  • 155
huaxz1986
  • 307
  • 5
  • 10

2 Answers2

6

If you really compile with gcc temp.c -o temp then you are not linking any libraries (except the default libc.6.so), and you need some additional argument to gcc ; perhaps try to compile with

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

Once your program is debugged with the help of the gdb debugger and you consider it to be bug-free, you may ask the compiler to optimize it using

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

The order of program arguments to gcc is important and significant.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
0

centos: yum install lksctp-tools-devel

yuloob
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 17 '22 at 02:03