Results 1 to 2 of 2
Thread: Compiling c++ code in bash
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Oct 2012
Compiling c++ code in bash
Anyway, I was sent a nice tar file with the directory I needed. Unpacked it and I have to .cpp files and like 5 or 6 .h files. Every time I try to compile, I get a load of errors from one specific .h file and my compilation aborts. Before I keep hacking away at this and try to do something crazy like debugging code I didn't write, I want to just double check with people that I'm executing the compilation commands correctly.
I downloaded g++ as my compiler. And I'm running with the command
g++ -c XXXX.cpp
Is this right, do I have to do anything like in FORTRAN where I link the .h files to the main files, or is the fact that the .h files are called in the source files sufficient.
Thanks in advance.
- Join Date
- Aug 2012
make sure that all the header file and .cpp file is in same directory.
try this command :-
g++ XXXX.cpp -o output_binary_name
you can run you code as below:-
go to terminal:- (chmod it if required)
ubuntu# chmod 777 output_binary_name ubuntu# ./output_binary_name
hope you got the answer.
if you still get the errors please post your errors here.