Reputation: 43
I am using C++ in VS Code, I have a simple SFML project. For some reason, when I compile and run my program, none of my cout statements are printed to the terminal window in VS Code. The SFML window opens and my program runs as expected but the lack of visible cout statements is hindering any debugging I try to do.
Test.cpp
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
cout << "This Is A Test" << std::endl;
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;
}
I run the following commands inside the VS Code terminal:
g++ -IC:/SFML/include -c Test.cpp -o "Test.out"
g++ -LC:/SFML/lib Test.out -o app.exe -lmingw32 -lsfml-graphics -lsfml-window -lsfml-system -lsfml-main -mwindows
./app.exe
I see an SFML window appear with a green circle as expected but do not see my cout message "This Is A Test"
Any help would be appreciated and if you need any more information from me I will be happy to provide it.
Upvotes: 0
Views: 126
Reputation: 43
Alright, well, genpfault left a comment that fixed the problem. I'll explain what the solution was for anyone who may be having a similar issue. Basically, my compilation command had the parameter "-mwindows," which apparently disables the console. I had unknowingly copied this command from somewhere online without checking what it actually did. So, moral of the story: if you're going to copy your code from online, learn what it's actually doing before blindly using it.
Upvotes: 2