Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I compile a .cpp file on Linux? [closed]

Tags:

c++

linux

I'm fairly comfortable with Linux and compiling things - I normally just follow the instructions and can manage to get myself out of trouble. This time, I was given a .cpp file by a random Internet citizen and I would really like to know how to compile it. Everything I seem to try (g++, c++, gcc) doesn't seem to work.

Anyhow, here's the file: http://pastebin.ca/2073013

Edit: Updated with verbose output from g++ file.cpp -o whatever: http://pastebin.ca/2073052

like image 822
pluc Avatar asked Jun 01 '11 00:06

pluc


2 Answers

You'll need to compile it using:

g++ inputfile.cpp -o outputbinary

The file you are referring has a missing #include <cstdlib> directive, if you also include that in your file, everything shall compile fine.

like image 115
loudandclear Avatar answered Oct 06 '22 23:10

loudandclear


The compiler is telling you that there are problems starting at line 122 in the middle of that strange FBI-CIA warning message. That message is not valid C++ code and is NOT commented out so of course it will cause compiler errors. Try removing that entire message.

Also, I agree with In silico: you should always tell us what you tried and exactly what error messages you got.

like image 31
David Grayson Avatar answered Oct 06 '22 23:10

David Grayson