Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/139.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Can';t编译c++;用SFML库编程_C++_Linker_Sfml - Fatal编程技术网

C++ Can';t编译c++;用SFML库编程

C++ Can';t编译c++;用SFML库编程,c++,linker,sfml,C++,Linker,Sfml,我现在想学习SFML库。 我的操作系统是Windows8.1,我不使用任何IDE,只使用Makefiles。编译器是g++mingw4.8.1 我已经从官方网站下载了SFML文件,然后将SFML的“include”文件夹复制到“include”——MinGW的文件夹、“lib”和“bin” 现在我想在官方网站上编译一个简单的程序,如示例中所示 #include <SFML/Graphics.hpp> int main() { sf::RenderWindow window(

我现在想学习SFML库。 我的操作系统是Windows8.1,我不使用任何IDE,只使用Makefiles。编译器是g++mingw4.8.1

我已经从官方网站下载了SFML文件,然后将SFML的“include”文件夹复制到“include”——MinGW的文件夹、“lib”和“bin”

现在我想在官方网站上编译一个简单的程序,如示例中所示

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
SFML的版本是2.2


我仍然需要帮助(请参见下面的注释)

尝试添加
-lstdc++
您能列出所有未解析的外部吗?这会有很大帮助。还要确保链接器搜索路径中有库文件的文件夹。您使用的是哪个版本的SFML?@OMGtechy在哪里可以编辑链接器搜索路径?
test.o:test.cpp:(.text+0xe5): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
test.o:test.cpp:(.text+0x10b): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
test.o:test.cpp:(.text+0x147): undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
test.o:test.cpp:(.text+0x17d): undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'
test.o:test.cpp:(.text+0x18e): undefined reference to `_imp___ZN2sf5Color5GreenE'
test.o:test.cpp:(.text+0x198): undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
test.o:test.cpp:(.text+0x1b8): undefined reference to `_imp___ZN2sf6Window5closeEv'
test.o:test.cpp:(.text+0x1cd): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
test.o:test.cpp:(.text+0x1ff): undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
test.o:test.cpp:(.text+0x21a): undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
test.o:test.cpp:(.text+0x22d): undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
test.o:test.cpp:(.text+0x241): undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
test.o:test.cpp:(.text+0x253): undefined reference to `_imp___ZN2sf6Window7displayEv'
test.o:test.cpp:(.text+0x262): undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
test.o:test.cpp:(.text+0x28b): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
test.o:test.cpp:(.text+0x2b2): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
test.o:test.cpp:(.text+0x2ec): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
c:/program files (x86)/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: test.o: bad reloc address 0xf in section `.text$_ZN2sf6StringD1Ev[__ZN2sf6StringD1Ev]'
c:/program files (x86)/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status