Hi,

I have just opened the Kdevelop interface to make my first C++ program. I think all I need to do first of all is click on the Project menu and then select New Project. Then click on the All Projects tab. This shows two options C and C++. So selectd C++ and it expanded giving more options underneath it such as CMake Based Project, Embedded, GTK, KDE, Kdevelop, QMake Project, wxWidgets. I selectd the QMake Project option and it expanded giving some more options underneath such as Simple ClanLib Application, Simple Hello World Program, Simple ncurses Hello World Program etc. I chose "Simple Hello World Program". Then I gave an application name like "first" and location of the file. As soon as I did this a new program called main.cpp was automatically written by Kdevelop and when I tried to execute it, a dialog box came with a message saying "There is no Makefile in this directory and no configure script for this project. Run automake and friends and configure first?" I clicked on "Run them" and a new windows opened with an output of the main.cpp file with the following message:

Hello World.
Press enter to continue...

I did so and closed down the Kdevelop ide. Then I restarted the IDE and clicked on File menu and chose New and created a new file with a name "two" and added the following code into it.

#include <iostream>     

using namespace std; 
         
int main()                            // Most important part of the program! 
{ 
  int age;                            // Need a variable... 
   
  cout<<"Please input your age: ";    // Asks for age 
  cin>> age;                          // The input is put in age 
  cin.ignore();                       // Throw away enter 
  if ( age < 100 ) {                  // If the age is less than 100 
     cout<<"You are pretty young!\n"; // Just to show you it works... 
  } 
  else if ( age == 100 ) {            // I use else just to show an example  
     cout<<"You are old\n";           // Just to show you it works... 
  } 
  else { 
    cout<<"You are really old\n";     // Executed if no other statement is 
  } 
  cin.get(); 
}

Saved it and clicked on "Execute program" button, the gearlike symbol, but to my surprise it did not give me the output it should have instead gave me the output of the previous main.cpp file as follows:

Hello World.
Press enter to continue...

Now can any one please tell me what to do? How can I make new files in this same project and execute them properly. This is driving me nuts, can't understand what is going wrong here. Thanks.

Recommended Answers

All 3 Replies

When you make changes to your code, you need to compile it to generate a recent version of your object file. You are getting the same output even after changing the program since its executing the previous executable.

Try compiling the new program and then pressing the execute button. Or look for a button named "compile and execute" which will do both the things for you.

When you make changes to your code, you need to compile it to generate a recent version of your object file. You are getting the same output even after changing the program since its executing the previous executable.

Try compiling the new program and then pressing the execute button. Or look for a button named "compile and execute" which will do both the things for you.

I did compile the new program and then execute it with the execute button (the gear icon), but still it does not execute and keep showing the output of the previous program. This is really weird, being new to programming I thought with Kdevelop IDE it will be a bit easier to write and run programs in c++, but this is now turning out to be a big frustration. Help please, thanks.

The thing here being that we can't see the setup or the configuration you have made with your IDE, so helping you out would be really difficult.

One thing you can try to do is create a new project from scratch, copy the contents of your program you want to the new file and then try out the same thing. It this doesn't work, then you have really messed up something somewhere, which I won't be able to tell from here.

Try out what I have said and then let me know the results.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.