SFML 在 VS 和 Qt 下的配置

文章目录

    • 下载
    • 解压
    • 配置环境变量
    • 配置 VS 环境变量
    • 配置 Qt .pro文件
    • 测试

下载

  • 官网链接:https://www.sfml-dev.org/download/sfml/2.5.0/
  • 下载与自己 VS 版本对应的压缩包

解压

  • 解压压缩包至某一路径,如:D:\SFML-2.5.0

配置环境变量

  • 我的电脑 - 高级系统设置 - 环境变量 - 系统变量 PATH,添加:D:\SFML-2.5.0\bin

配置 VS 环境变量

  • VC++ - 包含目录:D:\SFML-2.5.0\include
  • VC++ - 库目录:D:\SFML-2.5.0\lib
  • 链接器 - 附加依赖项:
sfml-graphics-s.lib;
flac.lib;
sfml-graphics-s-d.lib;
sfml-system-s.lib;
freetype.lib;
sfml-system-s-d.lib;
ogg.lib;
sfml-main.lib;
openal32.lib;
sfml-main-d.lib;
sfml-window.lib;
sfml-audio.lib;
sfml-window-d.lib;
sfml-audio-d.lib;
sfml-network.lib;
sfml-network-d.lib;
sfml-window-s.lib;
sfml-audio-s.lib;
sfml-window-s-d.lib;
sfml-audio-s-d.lib;
sfml-network-s.lib;
sfml-network-s-d.lib;
vorbis.lib;
sfml-graphics.lib;
vorbisenc.lib;
sfml-graphics-d.lib;
sfml-system.lib;
vorbisfile.lib;
sfml-system-d.lib;
  • 或者直接导入 .props 文件

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     <ImportGroup Label="PropertySheets" />
       <PropertyGroup Label="UserMacros" />
       <PropertyGroup>
           <IncludePath>D:\SFML-2.5.0\include;$(IncludePath)IncludePath>
           <LibraryPath>D:\SFML-2.5.0\lib;$(LibraryPath)LibraryPath>
       PropertyGroup>
   <ItemDefinitionGroup>
       <Link>
           <AdditionalDependencies>sfml-graphics-s.lib;flac.lib;sfml-graphics-s-d.lib;sfml-system-s.lib;freetype.lib;sfml-system-s-d.lib;ogg.lib;sfml-main.lib;openal32.lib;sfml-main-d.lib;sfml-window.lib;sfml-audio.lib;sfml-window-d.lib;sfml-audio-d.lib;sfml-network.lib;sfml-network-d.lib;sfml-window-s.lib;sfml-audio-s.lib;sfml-window-s-d.lib;sfml-audio-s-d.lib;sfml-network-s.lib;sfml-network-s-d.lib;vorbis.lib;sfml-graphics.lib;vorbisenc.lib;sfml-graphics-d.lib;sfml-system.lib;vorbisfile.lib;sfml-system-d.lib;%(AdditionalDependencies)AdditionalDependencies>
       Link>
   ItemDefinitionGroup>
 <ItemGroup />
Project>

配置 Qt .pro文件

# Config - Windows

INCLUDEPATH += D:\SFML-2.5.0\include\

CONFIG(debug,debug | release ){
     

LIBS += D:\SFML-2.5.0\lib\sfml-graphics-d.lib\
        D:\SFML-2.5.0\lib\sfml-window-d.lib\
        D:\SFML-2.5.0\lib\sfml-audio-d.lib\
        D:\SFML-2.5.0\lib\sfml-network-d.lib\
        D:\SFML-2.5.0\lib\sfml-system-d.lib\
}else{
     

}

测试

#include 

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;
}

你可能感兴趣的:(编程语言,-,C++,开发工具,-,VS,/,Qt,/,Sublimetext,SFML,SFML+VS)