终端进程终止,退出代码:3221226356

时间:2019-01-16 03:18:28

标签: c++ sfml

我正在VScode中工作,并使用msvc提供的cl编译器构建文件。它是一个简单的应用程序,具有一个main.cpp文件和SFML库。

当我尝试构建其编译器时,但是当我运行.exe时,我的程序关闭并给出以下消息:

终端进程终止,退出代码:3221226356

不知道问题出在哪里,有人可以帮我吗?

我已经在msdn网站上找到了答案和stackoverflow,但没有找到任何答案。我不知道问题可能出在我的compile.bat或task.json或main.cpp文件中。

main.cpp

#include <iostream>
#include <SFML/Graphics.hpp>

int main()
{
   sf::RenderWindow window;
   window.create(sf::VideoMode(800,608), "WORKS");
   sf::Event e;
   bool running = true;

   std::vector<sf::RectangleShape> shapes;

   for (int i = 0; i < 10; i++)
   {
       sf::RectangleShape temp;
       temp.setFillColor(sf::Color::White);
       temp.setSize(sf::Vector2f(32.0f,32.0f));
       temp.setPosition(i * 32 , 0);
       shapes.push_back(temp);
   }

   while(running)
   {
       while(window.pollEvent(e))
       {
           if (e.type == sf::Event::Closed)
           {
               window.close();
               running = false;
               break;
           }
       }

       window.clear(sf::Color::Black);

       for( auto shape : shapes)
       {
           window.draw(shape);
       }

       window.display();
   }

   std::cout << "ENDING" << std::endl;
   return 0;
}

compile.bat

@echo off
call "C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
set executablepath=..\bin\
set executablename=game.exe
set compilerflags=/Od /Zi /EHsc /W4 /Fe%executablepath%%executablename%
set includepaths=/I..\includes
set sourcefiles=main.cpp 
set libfiles=opengl32.lib freetype.lib flac.lib ogg.lib vorbis.lib 
vorbisenc.lib vorbisfile.lib sfml-system-d.lib sfml-window-d.lib sfml- 
graphics-d.lib sfml-audio-d.lib sfml-network-d.lib
call cd src
call cl %compilerflags% %includepaths% %sourcefiles%  /link 
/LIBPATH:../libraries/SFML %libfiles%
call cd ..\bin\
call game.exe

task.json

"version": "2.0.0",
"tasks": [
    {
        "label": "Compile & Run",
        "type": "shell",
        "command": "${workspaceRoot}\\.vscode\\compile.bat",
        "args": [],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "problemMatcher": {
            "owner": "cpp",
            "fileLocation": ["absolute"],
            "pattern": {
                "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                "file": 1,
                "line": 2,
                "column": 3,
                "severity": 4,
                "message": 5
            }
        },
    },

文件夹层次结构

Project Folder
|
|
--> .vscode -> compile.bat and tasks.json
|
|
--> bin -> EXE files with dll from sfml for dynamic linking
|
|
--> includes -> SFML hpp files
|
|
--> libraries -> SFML lib files
|
|
--> src -> main.cpp file

0 个答案:

没有答案