不能链接sctp二进制文件



我正在做一个网络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

问题是,当我将它们链接在两个不同的bin 服务器客户端时,它告诉我:

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

请注意,当我用-lsctp编译时,它编译得很好,但是,当我试图链接*。O文件,它像上面那样抱怨。另外,我已经安装了lksctp_tools并检查了我的内核是否支持checksctp

~ $ checksctp
Sctp supported

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

相关内容

  • 没有找到相关文章

最新更新