I'm using gedit on Ubuntu14.04 in C++, I run the program from the terminal but it throws an error:
g++: error: prueba.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
I have searched the internet and it says that I have to configure external tools manager, I have tried all the codes to compile, run and compile and run but it does not work. Please could you help me with this.
UPDATE: The problem can be found that when using the terminal you are not located in the same directory where you saved the test.cpp file. You have to be in the same directory for the command to work. Here is more information about how to navigate directories in Ubuntu . When you are in the same directory, you can use ls to see if `test.cpp is found, and try again.
To run a C++ program, you need a C++ compiler, like
g++
. You install it by runningsudo apt-get install build-essential
in a terminal, or by searching for the packagebuild-essential
in the Ubuntu Software Center. With the compiler, you produce a binary file, which is what you run.Gedit serves you mostly as an editor, although it does indeed have an option to run the command
make
with the F8 or F9 key, if I remember correctly. If you are not familiar with the concept ofmake
andmakefile
, it would not hurt to read about it . If you are not familiar with the concept of compiling code fromC++
, then you should also read , it is very important.If what you want is a program that you can use to edit code, compile and run the program, you need a full IDE, such as Eclipse CDT or Netbeans . These programs can detect the compilers you have, set all the compilation and linking options that are relevant to your project, and do it automatically at the click of a button. Just keep in mind that these programs are not lightweight at all.
What I do is do everything from the terminal, as César mentions in the other answer. When it's a slightly more serious project and not a simple test, I use
GNU make
.Although not exactly what you're asking for, you can have a terminal embedded in gedit. To do this you must install the gedit plugins
If you then go to preferences you can select "embedded terminal". This terminal appears and disappears with the keyboard combination
CTRL+F9
It is a convenient way to have a terminal in which to test the compilation and execution of your program or script. But first make sure the terminal is on the right path.
Well since
gedit
I don't think you can do it since it's just a text editor. What you have to do is compile it from your terminal usingg++
.For example, consider the following code in the file
prueba.cpp
:To compile it, navigate to the path where your file is located
prueba.cpp
:This will generate an executable file called
prueba
(thanks to the ) option-o
.Then, it only remains to execute it:
Here you can find a small guide to compile:
Update
You may need to install the package for
g++
previously. From your terminal: