在设置SFML静态库时遇到Code :: Blocks问题

时间:2017-08-17 15:39:24

标签: build codeblocks sfml

首先,我不得不说我只是初学c ++编程,所以这是我第一次尝试设置sfml 2.4.0。我在Ubuntu 16.04 LTS上运行Code :: Blocks。带有错误的脚本与SFML官方网站上的教程相同:

#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
using namespace std;

int main()
{
sf::RenderWindow finestra (sf::VideoMode(100,100), "Ciao!");
    sf::CircleShape cerchio (100.f);
    cerchio.setFillColor(sf::Color::Blue);
    while (finestra.isOpen())
    {
    sf::Event evento;
    while (finestra.pollEvent(evento))
    {
    if (evento.type == sf::Event::Closed)
    finestra.close();
    }
    finestra.clear();
    finestra.draw(cerchio);
    finestra.display();
    }
    return 0;
}

不要介意变量和字符串的奇怪名称,我只是想使用我的语言术语更熟悉脚本。 我尝试构建并运行脚本后出现的错误是这个(“riferimento non definito a”表示“未定义引用”):

||=== Build: Debug in primo_game_magari_serio (compiler: GNU GCC Compiler) ===|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|106|riferimento non definito a "glClearColor"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|107|riferimento non definito a "glClear"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|276|riferimento non definito a "glVertexPointer"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|277|riferimento non definito a "glColorPointer"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|278|riferimento non definito a "glTexCoordPointer"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|287|riferimento non definito a "glDrawArrays"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|311|riferimento non definito a "glGetError"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|321|riferimento non definito a "glPushClientAttrib"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|322|riferimento non definito a "glPushAttrib"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|324|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|325|riferimento non definito a "glPushMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|326|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|327|riferimento non definito a "glPushMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|328|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|329|riferimento non definito a "glPushMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|341|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|342|riferimento non definito a "glPopMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|343|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|344|riferimento non definito a "glPopMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|345|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|346|riferimento non definito a "glPopMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|348|riferimento non definito a "glPopClientAttrib"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|349|riferimento non definito a "glPopAttrib"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|374|riferimento non definito a "glDisable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|375|riferimento non definito a "glDisable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|376|riferimento non definito a "glDisable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|377|riferimento non definito a "glDisable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|378|riferimento non definito a "glEnable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|379|riferimento non definito a "glEnable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|380|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|381|riferimento non definito a "glEnableClientState"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|382|riferimento non definito a "glEnableClientState"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|383|riferimento non definito a "glEnableClientState"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|419|riferimento non definito a "glViewport"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|422|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|423|riferimento non definito a "glLoadMatrixf"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|426|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|444|riferimento non definito a "glBlendFunc"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|485|riferimento non definito a "glLoadMatrixf"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Shader.cpp|64|riferimento non definito a "glGetIntegerv"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Shader.cpp|984|riferimento non definito a "glFlush"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|66|riferimento non definito a "glGetIntegerv"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|72|riferimento non definito a "glGetIntegerv"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|124|riferimento non definito a "glDeleteTextures"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|166|riferimento non definito a "glGenTextures"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|214|riferimento non definito a "glBindTexture"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|215|riferimento non definito a "glTexImage2D"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|216|riferimento non definito a "glTexParameteri"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|217|riferimento non definito a "glTexParameteri"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|218|riferimento non definito a "glTexParameteri"|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

这里有项目的构建选项(我没有提到的那些被设置为默认值):

搜索目录/编译器:/home/user/Downloads/SFML-2.4.0/include

搜索目录/链接器:/home/user/Downloads/SFML-2.4.0/lib(我还试图添加另一个“/ include”但它也不起作用)

链接器设置/调试/ sfml-graphics-s-d SFML窗口-S-d sfml-system-s-d

链接器设置/发布/ sfml-graphics-s SFML窗口-S SFML系统-S

编译器设置/ #define / SFML_STATIC

我在论坛上搜索了一周以上非常单一的帖子,但我从来没有发现和我一样的问题。如果您需要其他信息,请提前感谢。

1 个答案:

答案 0 :(得分:0)

未定义的引用是opengl。您需要添加opengl库。

opengl32的窗口中,在所有sfml库之后添加

在linux中,我不太确定,但它看起来像GL

(奇怪的是SFML文档没有提到这一点。https://www.sfml-dev.org/tutorials/2.4/start-cb.php的windows版本确实提到了依赖关系,但截图没有显示库引用.linux构建指令根本没有提到它。 !当你开始工作时,你应该让他们更新文档。)