【问题标题】:SFML compile run missing dllSFML 编译运行缺少 dll
【发布时间】:2018-10-28 19:39:26
【问题描述】:

我在编译单个脚本时遇到问题。 我使用 SublimeText 和 MinGW 编译器。我输入了所有的 SFML 库。

这是代码:

    #include <SFML/Graphics.hpp>
#include <time.h>

using namespace sf;

    int main()
    {
        RenderWindow window(VideoMode(453,453),"Sachy");

        Texture t1;
        t1.loadFromFile("images/figures.png");

        Sprite s(t1);

        while(window.isOpen())
        {
            Event e;
            while(window.pollEvent(e))
            {
                if(e.type == Event::Closed)
                    window.close();
            }
            window.clear();
            window.draw(s);
            window.display();
        }
    }

然后在 cmd.exe 中运行:

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

编译没有错误。当尝试启动 a.exe 时显示此错误:

The code could not be started because libgcc_s_sjlj-1.dll was not found. Try to resolve this problem by reinstalling the program

【问题讨论】:

    标签: mingw sublimetext sfml


    【解决方案1】:

    您默认使用共享的 GCC 运行时,因此您编译的可执行文件将依赖它,您可以在 MinGW 的 bin 目录中找到它。

    如果您不想复制这些库,则可以改用静态运行时,方法是在命令行中添加以下两个选项:

    -static-libgcc -static-libstdc++
    

    请注意,这会增加生成的二进制文件的大小。

    【讨论】:

    • 我试试这个:g++ main.cpp -static-libgcc -static-libstdc++ -lsfml-graphics -lsfml-window -lsfml-system 还是同样的问题。
    • @ATomas 我猜你的 SFML 也取决于它。如果你是从源代码构建的,那么有一个 CMake 变量,现在不记得了。
    • 如果您使用静态库,您还需要-D SFML_STATIC 选项
    猜你喜欢
    • 1970-01-01
    • 2014-08-11
    • 2015-09-01
    • 2015-07-26
    • 1970-01-01
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多