1. in advance
We should be familiar with the relationship between C language and Linux. the Linux kernel is developed in C language. Therefore, all Linux systems will have C compilation and debugging tools, however, these tools are imperative and will be inconvenient for formal development. During the installation of Fedora, you can choose to install Fedora Eclipse. This IDE is very powerful and supports C, C ++, Java, Python, and so on, debugging, testing, and other functions are also complete. However, there is a problem with something too powerful, that is, the speed will be slow. on dave's machine, it takes 20 seconds to open Eclipse, and there are too many options to use. We want a fast, flexible, and powerful C development environment.
Code: Blocks is a cross-platform C/C ++ IDE. Supports Windows, Linux, and Mac operating systems and multiple compilers, such as Microsoft C, gnu c, Borland C, and Intel C. The gnu c version is included in Windows. In Linux, we don't need to attach it because the system has already been ready for us. Now let's install and try this IDE.
Ii. Installation
Fedora and other systems supporting YUM can be directly installed using the YUM command. Enter the following command under the root account:
Yum install codeblocks
Follow the prompts.
Ubuntu and other systems that support apt-get can be downloaded and installed using apt-get install codeblocks, or downloaded from the official website http://www.codeblocks.org/for further details.
Iii. Configuration
After the installation is successful, go to the main menu --> programming --> Code: Blocks IDE To enter the IDE. The first time you open the software, it will automatically detect the C compiler in the system, generally, gnu c is automatically detected in Linux.
Figure 1: Automatically detect the built-in Compiler
After detection, click OK to enter the software environment and you will see the Code: Blocks interface.
Figure 2: Code: Blocks default Interface
Do you think the toolbar on the window is messy? Drag it as you like and immediately become neat.
Figure 3: Adjusted page
On dave's machine, the path of the compiler detected by Code: Blocks is so problematic that the program cannot be compiled and the system BUG is unknown, so we need to further check the compiler path. Click Settings --> Compiler and debugger... go to the compiler and debugger Settings dialog box and check whether Selected Compiler is the compiler you want to use. Because we use gnu c by default, the gnu gcc Compiler is displayed here.
Figure 4: Default gnu c Compiler
Then, click the arrow next to Search directories four times to tag the Toolchain executables item. Then, check whether your Compiler path is entered in the text box under Compiler's installation directory. The default path of gnu c under Fedora is/usr/bin, and/usr/bin is displayed here. (If/usr is displayed, your settings are correct ), the following red line indicates that the compiler must be in the bin directory. Note: The Directory here cannot be/usr/bin. If/usr/bin is entered, Code: Blocks will find the compiler under/usr/bin, this is definitely a wrong path, but the default setting of the software is/usr/bin. This is a very bad bug. Enter/usr here. then confirm to exit.
Figure 5: Use the/usr path
Because Code: Blocks uses Xterm as the console interface for running the program by default, this software is not installed by default in Fedora, and this item is also antique. It does not support Chinese by default, we can use gnome-terminal (console in The Gnome Desktop Environment) as the default console. Of course, if you are a KDE Desktop Environment, you can select the KDE console. Click Settings --> Environment... in the menu bar to go to Environment Settings. In the displayed dialog box, you can see a line below:
Terminal to launch console programs:
The content of the text box on the right is:
Xterm-T $ TITLE-e
Figure 6: Environment setting page
Change the text box content:
Gnome-terminal-t $ TITLE-x
You can change the running console to the console that comes with Gnome.
If you want to use the default Xterm console, but the system is not installed, you can enter
Yum install xterm
To install Xterm.
Iv. Trial Run
The long-awaited time has finally arrived. The following is to run the Hello World Program. Click Fiel --> New --> Project... A new project dialog box is displayed, which contains different types of projects. Select Console application and click Go to create a new Console program.
Figure 7. Create a console Project
The following shows a useless window for creating a program. You can check in front of the Skip this page next time to get this annoying prompt to see God. Next, let us select the language type. Here we select C to compile the C language program (in fact, C ++ can also be used to compile the C language program --!), Next step. Enter our Project name in the text box under project title. Here I write ctest; Folder to create Project in: Enter the project path below, here I use/home/dave/cbwork. It will be automatically filled in the remaining two text boxes, regardless, directly Next.
Figure 8. Set the project path and name
Then, select the compiler and two project settings. After confirming the settings are correct, click Finish. At this time, Code: Blocks will display the created Project to the Mangement column on the left of the main window, which contains a main. c default file, click to open, you will find Hello World! The program has been written.
Figure 9. Created projects and documents
At this time, click the "Gear arrow" icon on the top of the screen to compile and run the program.
Figure 10. xterm Running Effect
Figure 11. gnome-terminal running effect
Now, you should have a preliminary understanding of some settings and usage of Code: Blocks. The rest is to write a program and get familiar with the software, this IDE will be further introduced in the future.