Results 1 to 2 of 2
So, I've recently been handed some code, and I'm trying to compile it. I've had experience with C++ but it was actually quite a few years ago.
Anyway, I was ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-24-2012 #1Just Joined!
- Join Date
- Oct 2012
- Posts
- 1
Compiling c++ code in bash
So, I've recently been handed some code, and I'm trying to compile it. I've had experience with C++ but it was actually quite a few years ago.
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.
- 10-25-2012 #2Just Joined!
- Join Date
- Aug 2012
- Posts
- 28
make sure that all the header file and .cpp file is in same directory.
try this command :-
after you give this command you will get exaculatble file named output_binary_name in the same directory you are currently in.Code:g++ XXXX.cpp -o output_binary_name
you can run you code as below:-
go to terminal:- (chmod it if required)
that's it.Code: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.


Reply With Quote
