run eclipse che by browser in ubuntu
when i run this code
#include <iostream>
main() {
std::cout << "Hello World!";
return 0; }
i got this error
cd /projects/my_prj && make && ./a.out
make: *** No targets specified and no makefile found. Stop.
what can i do for solve it?
To test that the required tooling is installed, try running this in the terminal:
cd /projects/my_prj
g++ -o a.out main.cc
(or whatever you called the C++ file you wrote above).
If you want a Makefile to build the project, you will need to specify a target (the default target will be "all") which has a rule for compiling the C++ code into a binary. The minimum would be something like this:
all:
g++ main.cc
Put this in a file called Makefile, and make sure that the 2nd line starts with a real tab, not an expanded one, and you should be good. There is a lot more to learn about Makefiles, but this will get you started.
Related
I have 2 cpp files(with one main function) in /home/misha/proga/c++again folder. I built C/C++: g++ build active task and modified it to compile all files in the folder above. Now, I need to add one more task to call a binary. I think I should add one more entry in "tasks" to finally be able to run a code. Where can I read about how to write this second task? I am new to programming. Is my approach correct to run this code contained in two files? I also do not know where this binary lies. Is it tasks file in .vscode folder ?
I use Ubuntu 19.10 and VSC 1.46.1
In Terminal,
cd /home/misha/proga/c++again
Let's suppose your two cpp files are mainFile.cpp and file2.cpp
If g++ (so GCC) was not installed in your system, you can install it by running this command on the Terminal:
sudo apt-get install gcc g++
and, to compile the program (read about invoking GCC, you want warnings and debug information), write this command into the Terminal:
g++ -Wall -g mainFile.cpp file2.cpp -o yourprog
Then, you can run the program by typing:
./yourprog
It should work now. You could need to use the GDB debugger and GNU make (to be installed with sudo apt-get install gdb make)
Read also some C++ programming book and this C++ reference.
I do not understand your approach usualy your create a makefile and compile your cpp files
g++ -g -c -fpic -o name.o
at the end you link them
g++ name.o 2name.o and so on
If you create binarys you should store them in /usr/lib
and the name should libname.so you can acces them by using the -l argument
I am trying to build a simple makefile for c++ using g++. Even a simple makefile is not working on my computer (MacOS X).
I followed this tutorial
Create the same files and makefile. I just replaced CC=gcc to CXX=g++, in makefile2. I am using c++ format for files.
I can compile it with g++, (in command line)
But when I try to make it by "make" command I get the following error.
make: *** No targets specified and no makefile found. Stop.
Format and directory are correct.
Any help is appreciated.
Here is makefile:
CXX=g++
CFLAGS=-I.
hellomake: hellomake.o hellofunc.o
$(CXX) -o hellomake hellomake.o hellofunc.o
"hellomake.cpp" :
#include "hellomake.h"
int main() {
// call a function in another file
myPrintHelloMake();
return(0);
}
hellofunc.cpp
#include <stdio.h>
#include "hellomake.h"
void myPrintHelloMake(void) {
printf("Hello makefiles!\n");
return;
}
hellomake.h
/*
example include file
*/
void myPrintHelloMake(void);
The issue was about makefile format. Initially it was makefile.rtf. Following comments I changed it to plain text (No extension) and the issue solved.
I'm currently trying to simply link a file called main.cpp with boost in order to do asio(asynchronous input and output). I'm using a makefile in order to compile the C++ code into executable form. However, despite using the -I modifier on my terminal command in Mac OS X, it still cannot find the appropriate directory to search in. Here is my code in Main
#include <asio.hpp>
int main(){
return 1;
}
and here is the makefile command that I am using
all:
g++ -Iboost_1_60_0/boost/ -o main main.cpp
In my file structure, boost_1_60_0, main.cpp, and makefile are all on the top level, where asio is in the folder boost which is in the folder boost_1_60_0. I'm very confused about this and any help would be appreciated! Thanks!
EDIT: Full error is
1 error generated.
make: *** [all] Error 1
iMats-2:SerialC++ wfehrnstrom$ make
g++ -Iboost_1_60_0 -o main main.cpp
main.cpp:2:10: fatal error: 'asio.hpp' file not found
You should use -Iboost_1_60_0 (or, better still, install Boost properly so that it's found automatically under /usr/include/), and write #include <boost/asio.hpp>.
The include directives inside Boost itself will assume this form, so…
BTW, this has nothing to do with exceptions. Presumably it's a compiler error you've seen.
i am trying to compile a c++ program in scons.
the scons works fine for c program but for c++ its giving the following error.
please can anybody help me about this, who knows about this?
first.cpp
#include <iostream>
int main()
{
std::cout << "hellooo" << std::endl;
return 0;
}
SConstructor
Program('first','first.cpp')
the error:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
o first.o -c first.cpp
sh: o: command not found
o first.exe first.o
sh: o: command not found
scons: done building targets.
what could be the problem in this?
You dont have a compiler for C++ installed, or at least SCons cant find it. Although you would expect SCons to explicitly tell you it cant find the compiler, I think what actually happens is it has a Construction Variable for the compiler that is actually empty, and it uses that to create the command line.
If you do indeed have it installed, you can fix this problem as follows:
env = Environment()
env.Replace(CXX = "/path/to/the/c++/compiler")
Today i got the most generic compile error for Dev-C++ ever
Compiler: Default compiler
Building Makefile: "C:\projects\Makefile.win"
Executing make...
make.exe -f "C:\projects\Makefile.win" all
g++.exe -c test.cpp -o test.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/SDL-1.2.15/include"
make.exe: *** [test.o] Error 255
Execution terminated
and that's it. I googled around online but usually you can see some other type of errors follow it within the compile log but no in my case. Anyone help. I am running this on window 8
Please update your IDE to the following version, which fixes an immense list of bugs, ships with GCC 4.6.1 or 4.7.0, and is fully portable: http://sourceforge.net/projects/orwelldevcpp/
That would be the number one fix to try and fix this problem regarding the automatically generated makefile. Chances are the updated version will fix your makefile problems.
You could also open up the auto generated makefile yourself and:
Go to Project >> Project Options >> Makefile and tick "use custom makefile".
Try to fix the makefile manually.
???
Rebuild.
Profit.
If this option was previously left unticked, you are sure either the old Dev-C++ made an error creating the makefile or the bundled compiler got broken for some reason.