0

I've been trying to get into C++ programming with Eclipse, but I'm having problems setting up Eclipse.

I have MinGW installed and in the environment path, and I created the simple C++ project with the following source code:

#include <iostream>

int main(void)
{
    std::cout << "what is your name? ";
    std::string name;
    std::cin >> name;
    std::cout << "Hello, " << name << std::endl;
    std::cin.ignore();
    return 0;
}

After successfully building the project (both debug and release configurations), I click the run button and there's no output. The program terminates immediately. I've also tried running in debug mode, but then it will wait for me to type in a name, then display all the output. example console:

scott

what is your name? Hello, scott

I've tried this with both the 32 and 64 bit Windows versions of Eclipse Helios and both versions have the same behavior. Does anyone know what is going on and how to fix this?

I've run the program from the command-line and it works as intended.

edit: After some tinkering around, I found that by copying the MinGW dll's into the same folder as the executable the program will run in Eclipse just fine. Is there an alternative method to have Windows find the dll's in MinGW's bin folder rather than have to copy them over each time?

1
  • Not sure if this is your problem, but you should put a << std::flush at the end of your prompt to be sure your prompt is shown before waiting for input. Also, you need #include <string>. Commented Jun 6, 2011 at 14:55

1 Answer 1

2

Is there an alternative method to have Windows find the dll's in MinGW's bin folder rather than have to copy them over each time?

Set the PATH environment variable in the run configuration settings (Run -> Run Configurations... -> Environment).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.