1. Platform build Linux If it is simple to build a C build environment, is relatively easy to implement, because the system built-in compiler gcc, so we have to do is just write the C source file and then compile it can be if there is no GCC compiler, use the following command to get ~# sudo Apt-get install gcc also download the accessibility tool ~# sudo apt-get install binutils header Vault ~# sudo apt-get install llibc6-devclibrary (used to query syntax usage documents ) ~# sudo apt-get install Glibc-doclinux under C language Programming reference document ~# sudo apt-get install Glibc-doc-referenc function usage Note Document ~# sudo apt-get insta ll Manpages-dev program used to connect multiple source files to generated target files make~# sudo apt-get install makemake program usage Instructions document ~# Man getch~# man made check after help, Press Q to exit document 2. After the program has been written, compiled and run, you can find Kate in the app > others, open it in the syntax highlighting and indenting in the Tools menu, and then write your own C program, such as: #include <stdio.h> int main (int argc, char **argv) {System ("clear"); printf ("Hello world!\n"); return 0;} After entering the program and save with Ctrl+s, I assume that the save path is/home/user1/desktop/helloworld/hello.c then compile, open terminal, enter directory # cd/home/user1/desktop/helloworld/ Then compile with gcc # gcc-wall HELLO.CGCC will show errors found during compilation, and if no error occurs, it will be compiled into a file a.out run program (a.out to compile generated files) #./a.out This time the screen will show Hello world! ~ #表示编译运行成功-------------------Other instructions: ubuntu8.04 default does not support Getch (), GetChar (), get () and other functions, if you want to use then need to install curses library file # sudo apt-get Install Libncurses5-dbg# sudo apt-get isntall libncurses5-dev and add #include<curses.h> when writing source code or add-lcurses parameters when compiling with GCC, for example: # Gcc-wall./hello.c-lcurses can use functions such as getch. Note: The Getch function does not play a role in suspending the program under the Linux console. You can use GetChar instead of getch to achieve this function--------------------------tips: If you write a larger program, it takes a long time to complete, you can build a launcher for quick and easy to compile, For example, you have to spend a lot of days to write a source program, you can build a launcher on the desktop, point to the C program in the directory, the starter command is as follows (here the C source program in the/home/user1/desktop/hello/directory for example) Gnome-terminal-- working-directory=/home/user1/Desktop/hello/Open this starter every time you compile, you can directly use GCC to compile the source program file name without having to enter a long path ~# gcc-wall hello.c
Compiling the C language under Ubuntu