A few days ago, I started simple programming and development in the Linux environment. I made some simple transcripts in the process, but the company's project was too busy. I didn't have time to organize the transcript into a blog post.
1. If the path is incorrect, it is always prompted that the corresponding file cannot be found in this path. I wrote a helloworld to start programming and development in Linux. After the vim IDE and GCC compilation tools are installedSource codeAfter compilation, I tried it many times but kept prompting that my CPP file could not be found under the path. I thought it was a path problem, I also checked some information about the Linux file path. I think this path should be correct. Are there other problems? Change the CPP file to the C file and compile it. It turns out that GCC is used to compile CPP. The compilation of CPP files also requires the installation of G ++. I was so confused that I had no idea about the compilation principles in Visual Studio. During development, you can use sudo apt-Get install build-essential to install the necessary compiling environment.
2. Compile multiple C files and link them to an application.Program. Gcc-g-wall helloword. c hellofunc. C-o helloworld.
3. For makefile problems, add the MAKEFILE file under the folder where the c file is located, and enter "make" on the command line terminal ", the Make tool can compile and link C files and Their generated o files according to the makefile rules. The "make parameter" parameter is an operation defined in the MAKEFILE file.
4. When writing makefile, pay attention to the situation that the name of the eventually linked application must be the same as the name of the C file containing the main function or the generated o file, otherwise, the corresponding application cannot be generated. The Make tool is a good thing. It can help you easily compile the entire project. It uses the relationships between objects defined in makefile to determine whether to re-compile all files, in this way, if a part of a large project is changed, you do not need to compile the other part. After all, it is very painful.
5. You can specify the compiler used for compilation and some compilation options in makefile. For example, Cc = GCC indicates that the GCC compiler is used, while cflags =-wall indicates the compilation options, the same principle is true for using command line compiling.
6. To run the generated application, you cannot directly enter CD on the command line terminal to go to the corresponding path, and then enter the application name to start the application, however, no matter which path the command line terminal is transferred to, if you need to run the application, even if you have already transferred it to the Application Path, you cannot run it by directly entering the application name. The full path, such as/home/Allen/desktop/helloworld, must be provided in any case. The case sensitivity of the Ubuntu command line terminal is different. (Points 1 to be verified)
7. GCC is the abbreviation of GNU complier collection, meaning a collection of multiple GNU compilers, it is a set of compilers for C, C ++, Fortran, Java, Ada, and their corresponding libraries. Using GCC to compile C source code can be compiled directly with GCC, because at the beginning, GCC is the abbreviation of gnu c Complier, that is, GCC is the native compiler of C. Compiling C ++, Fortran, and other languages requires linking their standard libraries during compilation, alternatively, you can use the compiling frontend they specify to compile, such as gcc-g-wall helloworld. CPP-lstdc ++-O hello this-lstdc ++ uses the-l compilation option to bring libstdc ++. the C ++ standard library a is linked together during the link, you can also use a front-end such as G ++ to compile the source file g ++-g-wall helloworld as conveniently as using gcc. CPP-O hello, And the Fortran language also has a gfortran front-end compilation mark, which is used like G ++.
8. Database Link. For example, GCC-g-wall helloworld. c/usr/lib/libieee. a-O hello, this is a troublesome way of writing. Generally, use the compile option-L from the seventh point above, and then add the file name after Lib in the standard library file, as in the previous example, GCC-g-wall helloworld. c-lieee-O hello.
OK. If you have time, continue to study programming in Linux.