Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22267

Tried to get SFML to work but now I can't run any other C++ files in the project folder cause of an error with cl.exe

$
0
0

Now whenever i press the run button on any of my cpp projects not just the sfml project that I'm talking about, it gives me the error cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS.

But my project is supposed to be for gcc not for the developer command prompt for VS. And when I do ctrl+shift+b I get:

'cl.exe' is not recognized as an internal or external command.

This is the code in my code file, and this is the actual cpp code file with the code:

#include <SFML/Graphics.hpp>int main(){    sf::RenderWindow window(sf::VideoMode({200, 200}), "SFML works!");    sf::CircleShape shape(100.f);    shape.setFillColor(sf::Color::Green);    while (window.isOpen())    {        while (const std::optional event = window.pollEvent())        {            if (event->is<sf::Event::Closed>())                window.close();        }        window.clear();        window.draw(shape);        window.display();    }}

And if i change it to the code:#include <SFML/Graphics.hpp>

int main() {    sf::RenderWindow window(*sf*::VideoMode(800, 600), "Bouncing Ball");    sf::CircleShape ball(20);    ball.setFillColor(sf::Color::Red);    sf::Vector2f velocity(0.3f, 0.3f);    while (window.isOpen()) {        sf::Event *event*;        while (window.pollEvent(*event*)) {            if (event.*type* == *sf::Event::Closed*) {                window.close();            }        }        // Move the ball        ball.move(velocity);        // Check for collisions with window boundaries        if (ball.getPosition().x < 0 || ball.getPosition().x + ball.getRadius() * 2 > window.getSize().x) {            velocity.x = -velocity.x;        }        if (ball.getPosition().y < 0 || ball.getPosition().y + ball.getRadius() * 2 > window.getSize().y) {            velocity.y = -velocity.y;        }        window.clear(sf::Color::Black);        window.draw(ball);        window.display();    }    return 0;}

There is 5 different red sguiggly lines that starredAnd when I put it into an AI it couldn't fix

I followed a tutorial and I downloaded GCC 14.2.0 MinGW (SEH) (UCRT) on https://www.sfml-dev.org/download/sfml/3.0.0/#windows cause I got the gcc from a folder called x86_64-14.2.0-release-posix-seh-ucrt-rt_v12-rev0.

Then i went to c_cpp_properties.json in my .vscode and added the path to my SFML3.0.0/include. And within that folder is a bunch of projects where one of them is my project that uses SFML, and that one has it's own .vscode folder with a tasks.json and launch.json file.

This is my tasks.json file for my sfml project:

    {"version": "2.0.0","tasks": [        {"label": "build","type": "shell","command": "g++","args": ["-g","${workspaceFolder}/redBallBouncing.cpp","-o","${workspaceFolder}/redBallBouncing","-I","C:\\Users\\This_Is_Where_My_User_Profile_Name_Would_Be\\OneDrive\\Documents\\Libraries\\SFML-3.0.0\\include","-L","C:\\Users\\This_Is_Where_My_User_Profile_Name_Would_Be\\OneDrive\\Documents\\Libraries\\SFML-3.0.0\\lib","-lsfml-graphics","-lsfml-window","-lsfml-system"          ],"group": {"kind": "build","isDefault": true          },"problemMatcher": ["$gcc"]        }      ]    }

And this is the launch.json file for my sfml project:

    {"version": "0.2.0","configurations": [        {"name": "Debug","type": "cppdbg","request": "launch","program": "${workspaceFolder}/redBallBouncing","args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": false,"MIMode": "gdb","setupCommands": [            {"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true            }          ],"preLaunchTask": "build","miDebuggerPath": "C:/mingw-w64/x86_64-14.2.0-release-posix-seh-ucrt-rt_v12-rev0/mingw64/bin/gdb.exe","logging": {"engineLogging": false,"trace": false,"traceResponse": false          }        }      ]    }

I also added the path to the SFML lib in my PATH on system variables.


Viewing all articles
Browse latest Browse all 22267

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>