Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #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.

  2. #2
    make sure that all the header file and .cpp file is in same directory.
    try this command :-
    g++ XXXX.cpp -o output_binary_name
    after you give this command you will get exaculatble file named output_binary_name in the same directory you are currently in.
    you can run you code as below:-
    go to terminal:- (chmod it if required)
    ubuntu# chmod 777 output_binary_name
    ubuntu# ./output_binary_name
    that's it.

    hope you got the answer.
    if you still get the errors please post your errors here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts