Recently, you need to upload your code to GitHub, which allows the code to be compiled and run on Ubuntu. I learned a little bit about how to compile C + + files in the Ubuntu environment. A single source file generates an executable program
Casually write a simple program:
/*test.cpp*/
#include <iostream>
int main (int argc,char *argv[])
{
std:: cout << "Hello, World" << Std::endl;
return (0);
}
Can be directly g++ test.cpp compile, * compiler default action: * Compile source code file to generate object file, link object file and function in LIBSTD C + + library to get executable program. The object file is then deleted. The compiler takes the default a.out because the file name of an executable program is not specified on the command line. Programs can run like this:./a.out
However, the general practice specifies the output name, as follows:
g++ test.cpp-o test multiple source files to generate an executable file:
In fact, the compiler is now very smart, you only need to put all the engineering use of the. cpp and. h files under the same file directory, and then g++ *.cpp-o test can be compiled into an executable file.
Note: It should be noted that if the method used in the project is not in the standard library, then you need to rewrite this method. For example, I use vs 2012 to build the project inside the STRLWR method is not in the standard library, then the use of Linux compilation will be reported without the definition of errors.