Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1011079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:10:51+00:00 2026-05-16T09:10:51+00:00

I am trying to compile my first c++ file on windows with the g++

  • 0

I am trying to compile my first c++ file on windows with the g++ compiler…

My cpp file is the following –

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

I type in this on command prompt to get to the directory

cd C:\Users\Mark

Then to compile my program I do

g++ hello.cpp

It creates a file name a.exe (default) but when I click on it the command prompt quickly flashes open then it’s gone.

What did I do wrong? It should say Hello World! on the prompt and stay there, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T09:10:52+00:00Added an answer on May 16, 2026 at 9:10 am

    What you did looks correct, but if you start the program by double clicking it in Windows, the new command prompt will be closed once it is finished. Since you already have a command prompt open for compilation, try to start the program from there, too:

    g++ hello.cpp -o hello.exe
    hello.exe
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile my first .ui file using PyQt4 on a mac with
I've this following code in C++: //file0.cpp #include file11.cpp #include file22.cpp #include<iostream> #include<conio.h> using
I'm trying to compile this program using MinGW on Windows 7. On my first
I am trying to compile this .c code in windows using MinGW (gcc file.c
I am trying to start using cython and and attempting to compile my first
Iam trying to compile a file of the following format by making a parser
I am trying to include 2 platform-specific stdafx.h files in my .cpp file, but
I'm having problems when trying to compile the following code: I first tried compiling
i'm trying to compile my code with g++ C++ compiler on Windows and the
While trying to compile a 64 bit linux kernel using gcc, I see the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.