SFML 2.1 RenderWindow链接错误 [英] SFML 2.1 RenderWindow linking error

查看:709
本文介绍了SFML 2.1 RenderWindow链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    while(window.isOpen())
    {
        sf::Event Event; 
        while(window.pollEvent(Event))
        {
            if(Event.type == sf::Event::Closed || Event.key.code == sf::Keyboard::Escape)
                window.close();
        }

        window.display();
    }
    return 0; 
}

我的编译器调用:

g++ main.cpp -framework SFML -lsfml-graphics -lsfml-window -lsfml-system

错误消息:

Undefined symbols for architecture x86_64:
      "sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
      _main in cc8BMfpR.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

是RenderWindow在图书馆里我忘了链接?我假设它是在'窗口'一个..我运行SFML 2.1并尝试各种链接组合,所有这些都给我链接错误。这个链接链是给我最小的错误,即RenderWindow错误。有人帮我弄清楚了吗?我在这里有点失落。我在mac os 10.8上运行。

Is RenderWindow in a library I forgot to link? I assumed it was in the 'window' one.. I'm running SFML 2.1 and tried various linking combinations, all of which give me linking errors. This linking chain is the one that gives me the least error, namely the RenderWindow error. Someone help me figure this out? I'm at a bit of a loss here. I'm running on mac os 10.8.

推荐答案


在库中我是RenderWindow我忘了链接?我认为它是在'窗口'一个..

Is RenderWindow in a library I forgot to link? I assumed it was in the 'window' one..

它在图形包。因此在sfml图形。但你已经链接了那一个。但是,您不能假定链接到SFML.framework(它只包含头文件)。

It's in the graphics package. Hence in sfml-graphics. But you already linked that one. However, you're not suppose to link against SFML.framework (it contains only header files).

如上所述这里,你可以使用框架或dylibs。您的程序可以用以下任意一种编译:

As stated here, you can use either frameworks or dylibs. Your program can be compiled with either:

g++ main.cpp -lsfml-graphics -lsfml-window -lsfml-system

g++ main.cpp -framework sfml-graphics -framework sfml-window -framework sfml-system

现在,关于架构x86_64 错误的未定义符号,我只能猜测你没有从下载页面。如果您要使用g ++,请下载GCC版本。

Now, regarding the Undefined symbols for architecture x86_64 error, I can only guess you didn't download the compatible version from the download page. If you want to use g++, download the "GCC" version.

或者,切换到 clang 。 (例如,您可以在此处查看该ang可以比GCC更快。)

Or, switch to clang. (E.g., you can see here that clang can be faster than GCC.)

这篇关于SFML 2.1 RenderWindow链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆