compiling, building and executing a C++ program in Anjuta

Asked by akumudzi

I'm new to Linux and want to learn programming c++ on it.
When i write a simple 'Hello world' program in Anjuta,

#include <iostream>
using namespace std;
int main () {

 cout << "Hello world";
 return 0;
}

it gives me the following errors during compiling:

gsh: gtkmm-config: command not found
sh: gnome-config: command not found
sh: wx-config: command not found
Completed... successful

and when I build the program it gives the following errors:

g++: `gtkmm-config: No such directory
g++: `gnome-config: No such directory
g++: `gnomemm`: No such directory
g++: `wx-config: No such directory
g++: `gtkmm-config: No such directory
g++: `gnome-config: No such directory
g++: `gnomemm`: No such directory
g++: `wx-config: No such directory
cclplus: error: unrecognized command line option "-fcflags`"
cclplus: error: unrecognized command line option "-fcflags"
cclplus: error: unrecognized command line option "-fcxxflags`"
cclplus: error: unrecognized command line option "-flibs`"
cclplus: error: unrecognized command line option "-flibs"
cclplus: error: unrecognized command line option "-flibss`"
Completed... unsuccessful

and so I think this is the reason why when I try to execute the program a warning message prompt says:
 "No executable for this file"

What do i need to do to have a c++ environment that compiles and executes programs?

thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Anjuta Edit question
Assignee:
No assignee Edit question
Solved by:
Rafael Sachetto
Solved:
Last query:
Last reply:
Revision history for this message
Rafael Sachetto (rsachetto) said :
#1

Try this: Open a terminal and type

sudo apt-get install build-essential libgtkmm-dev libgnome-dev

Revision history for this message
akumudzi (limbikani) said :
#2

thnx rafaelI.
I did that and for compiling the errors have changed to:

Unknown library `gnomemm`
sh: wx-config: command not found

and for building the same errors are still coming and therefore completing unsuccessful.

Revision history for this message
Rafael Sachetto (rsachetto) said :
#3

Open a terminal, go to your c++ src directory:

#cd /path_to_you_c++_src

then try:

#g++ your_cpp_file.cpp -o program_name

See what you get

Revision history for this message
akumudzi (limbikani) said :
#4

thanx Rafael,

this successfully created the executable. and executing the program now works, however, I would like to know if I'll have to run this command every time I need to build a program. Is this the standard way or something is wrong with my Anjuta?

Revision history for this message
Best Rafael Sachetto (rsachetto) said :
#5

Probably this is a problem with you anjuta configuration.
This command is the command line way to build a program using g++.
You could try another IDE's like eclipse: http://www.eclipse.org/downloads/
Or codeblocks: http://wiki.codeblocks.org/index.php?title=Compiled_packages_of_Code::Blocks

or try to configure your anjuta properly.

Revision history for this message
akumudzi (limbikani) said :
#6

thanks