不能 link sctp 二进制文件

Cannot link sctp binary

我正在做一个网络 C 库,我也想支持 SCTP。 我在这个文件中有 wrapper_socket_functions.c

/*SCTP WRAPPER */
void
Sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt, int flags)
{
    int rbindx = sctp_bindx(sd, addrs, addrcnt, flags);
    if(rbindx == -1)
        prog_error("Sctp_bindx error",true,errno);
}
void
Sctp_connectx(int sd, struct sockaddr *addrs, int addrcnt, sctp_assoc_t *id)
{
    int rconnectx = sctp_connectx(sd, addrs, addrcnt, id);
    if(rconnectx == -1)
        prog_error("Sctp_connectx error",true,errno);
}
int
Sctp_peeloff(int sd, sctp_assoc_t assoc_id)
{
    int rpeeloff = sctp_peeloff(sd, assoc_id);
    if(rpeeloff == -1)
        prog_error("Sctp_paleof error",true,errno);
    return rpeeloff;
}

我有这个 makefile。

CC = gcc
CFLAGS = -lsctp -c -std=gnu11 -g -Wall -o
LIB_PATH = lib/
BIN_PATH = bin/

OBJECTS_LIBRARY = bin/error.o bin/signal.o bin/io_socket.o bin/wrapper_socket_functions.o bin/wrapper_stdio.o bin/wrapper_convert.o bin/wrapper_io_socket.o bin/wrapper_unix.o bin/handlers.o bin/miscellaneous.o bin/protocol.o
CLIENT_FILES = bin/client.o
SERVER_FILES = bin/server.o

all:

    #Compile MAIN_FILES

    $(CC) $(CFLAGS) $(BIN_PATH)client.o client.c
    $(CC) $(CFLAGS) $(BIN_PATH)server.o server.c

    #Compile LIB_FILES

    $(CC) $(CFLAGS) $(BIN_PATH)handlers.o $(LIB_PATH)handlers.c
    $(CC) $(CFLAGS) $(BIN_PATH)signal.o $(LIB_PATH)signal.c
    $(CC) $(CFLAGS) $(BIN_PATH)error.o $(LIB_PATH)error.c
    $(CC) $(CFLAGS) $(BIN_PATH)wrapper_socket_functions.o $(LIB_PATH)wrapper_socket_functions.c
    $(CC) $(CFLAGS) $(BIN_PATH)wrapper_stdio.o $(LIB_PATH)wrapper_stdio.c
    $(CC) $(CFLAGS) $(BIN_PATH)wrapper_convert.o $(LIB_PATH)wrapper_convert.c
    $(CC) $(CFLAGS) $(BIN_PATH)wrapper_io_socket.o $(LIB_PATH)wrapper_io_socket.c
    $(CC) $(CFLAGS) $(BIN_PATH)io_socket.o $(LIB_PATH)io_socket.c
    $(CC) $(CFLAGS) $(BIN_PATH)wrapper_unix.o $(LIB_PATH)wrapper_unix.c
    $(CC) $(CFLAGS) $(BIN_PATH)miscellaneous.o $(LIB_PATH)miscellaneous.c
    $(CC) $(CFLAGS) $(BIN_PATH)protocol.o $(LIB_PATH)protocol.c
    #Link CLIENT

    $(CC) -o $(BIN_PATH)client $(OBJECTS_LIBRARY) $(CLIENT_FILES)

    #Link SERVER

    $(CC) -o $(BIN_PATH)server $(OBJECTS_LIBRARY) $(SERVER_FILES)

    #Remove unwanted objects

    rm -rf bin/*.o

问题是当我 link 它们在两个不同的 bin serverclient 中时,它告诉我这个:

undefined reference to sctp_bindx undefined reference to sctp_connectx undefined reference to sctp_peeloff

请注意,当我使用 -lsctp 编译时,它编译得很好,但是当我尝试 link 那个 *.o 文件时,它会像上面那样抱怨。我还安装了 lksctp_tools 并使用 checksctp

检查我的内核是否支持它
~ $ checksctp
Sctp supported

删除 CFLAGS arg -lsctp 并将其添加到 LINKFLAGS = -lsctp 中,并在链接时添加到 $(CC) $(LINKFLAGS).

之后