SFML Networking Error: undefined references des when linking

SFML Networking Error: undefined references des when linking

我最近开始学习SFML,但是当我到网络部分时,总是会出现很多错误:

obj\Release\main.o:main.cpp:(.text$_ZN2sf11TcpListenerD1Ev[__ZN2sf11TcpListenerD1Ev]+0x1): undefined reference to `_imp___ZTVN2sf11TcpListenerE'
obj\Release\main.o:main.cpp:(.text$_ZN2sf11TcpListenerD1Ev[__ZN2sf11TcpListenerD1Ev]+0xb): undefined reference to `_imp___ZN2sf6SocketD2Ev'
obj\Release\main.o:main.cpp:(.text$_ZN2sf9TcpSocketD1Ev[__ZN2sf9TcpSocketD1Ev]+0x1): undefined reference to `_imp___ZTVN2sf9TcpSocketE'
obj\Release\main.o:main.cpp:(.text$_ZN2sf9TcpSocketD1Ev[__ZN2sf9TcpSocketD1Ev]+0x25): undefined reference to `_imp___ZN2sf6SocketD2Ev'
obj\Release\main.o:main.cpp:(.text$_ZN2sf9TcpSocketD1Ev[__ZN2sf9TcpSocketD1Ev]+0x2f): undefined reference to `_imp___ZN2sf6SocketD2Ev'
obj\Release\main.o:main.cpp:(.text$_ZN2sf11TcpListenerD0Ev[__ZN2sf11TcpListenerD0Ev]+0x7): undefined reference to `_imp___ZTVN2sf11TcpListenerE'
obj\Release\main.o:main.cpp:(.text$_ZN2sf11TcpListenerD0Ev[__ZN2sf11TcpListenerD0Ev]+0x12): undefined reference to `_imp___ZN2sf6SocketD2Ev'
obj\Release\main.o:main.cpp:(.text$_ZN2sf9TcpSocketD0Ev[__ZN2sf9TcpSocketD0Ev]+0x7): undefined reference to `_imp___ZTVN2sf9TcpSocketE'
obj\Release\main.o:main.cpp:(.text$_ZN2sf9TcpSocketD0Ev[__ZN2sf9TcpSocketD0Ev]+0x23): undefined reference to `_imp___ZN2sf6SocketD2Ev'
obj\Release\main.o:main.cpp:(.text.startup+0x60): undefined reference to `_imp___ZN2sf9IpAddress15getLocalAddressEv'
obj\Release\main.o:main.cpp:(.text.startup+0x72): undefined reference to `_imp___ZN2sf9TcpSocketC1Ev'
obj\Release\main.o:main.cpp:(.text.startup+0x129): undefined reference to `_imp___ZN2sf9TcpSocket4sendEPKvj'
obj\Release\main.o:main.cpp:(.text.startup+0x159): undefined reference to `_imp___ZN2sf9TcpSocket7receiveEPvjRj'
obj\Release\main.o:main.cpp:(.text.startup+0x1f7): undefined reference to `_imp___ZN2sf9TcpSocket7connectERKNS_9IpAddressEtNS_4TimeE'
obj\Release\main.o:main.cpp:(.text.startup+0x226): undefined reference to `_imp___ZN2sf11TcpListenerC1Ev'
obj\Release\main.o:main.cpp:(.text.startup+0x243): undefined reference to `_imp___ZN2sf11TcpListener6listenEt'
obj\Release\main.o:main.cpp:(.text.startup+0x259): undefined reference to `_imp___ZN2sf11TcpListener6acceptERNS_9TcpSocketE'

我正在使用 CodeBlocks,编译器参数是:

mingw32-g++.exe -LC:\Users\Justin\AppData\Roaming\CodeBlocks\SFML-2.2\lib -o "bin\Release\SFML Test.exe" obj\Release\main.o  -s  -lsfml-graphics -lsfml-window -lsfml-system

只有在我使用网络功能时才会出现这种情况,没有其他情况(但我还没有尝试过音频)。

提前致谢。

编辑:这是我的代码:

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
using namespace sf;

#include <iostream>
#include <string>

#define cout std::cout
#define endl std::endl

int main(){
    IpAddress ip = IpAddress::getLocalAddress();
    TcpSocket socket;
    char connectionType, mode;
    char buffer[2000];
    std::size_t recieved;
    std::string text = "Connected to: ";

    cout << "Enter (s) for server; Enter (c) for client: ";
    std::cin >> connectionType;

    if(connectionType == 's'){
        TcpListener listener;
        listener.listen(123456);
        listener.accept(socket);
        text += "Server";
    }else if(connectionType == 'c'){
        socket.connect(ip, 123456);
        text += "Client";
    }else{
        cout << "ERROR: Wrong Connection Type";
    }

    socket.send(text.c_str(), text.length());

    socket.receive(buffer, sizeof(buffer), recieved);

    cout << buffer << endl;

    system("pause");
}

Link 网络模块:

 mingw32-g++.exe -LC:\Users\Justin\AppData\Roaming\CodeBlocks\SFML-2.2\lib -o "bin\Release\SFML Test.exe" obj\Release\main.o  -s  -lsfml-graphics -lsfml-window -lsfml-system -lsfml-network