1. kdevelop is just an ide. To compile a C/C ++ program, install make, GCC, And the header file:
Sudo apt-Get build-dep gcc
Sudo apt-Get install build-essential
2. Install kdevelop
Sudo apt-Get install kdevelop3
3. After installation, You can see kdevelop in Application> programming. The following code uses kdevelop to develop a program, and you can steal it :-)
Procedure
GenerallyKdevelopProgramming involves the following steps. Programming is complicated and difficult to succeed at a time. These steps may need to be repeated multiple times.
Step 1: Create a project
You can use the menu to start the corresponding Wizard program and use it to complete the initial construction of the project.
[Project] → [new project]
When creating a project, you must specify the storage location, project name, and project type of the project file, and enter the information of the programming author. The wizard automatically generates a batch of template files based on the selected project type (for example, a text interface program or a graphic interface program, a C program or a C ++ program.
Step 2: edit the program file
Wizard programs generally create some program files, which should be edited to meet specific programming needs. You can also execute menu operations to add new files.
[File] → [new]
After the preceding operations, a dialog box is displayed to specify the file name and file type. Depending on the file type, the appropriate extension is automatically set. Note: The "add to project" check box should be checked to ensure that the new file is added to the current project.
Step 3: generate the source code structure
After editing the program file, you must use the GNU build system to generate the source code structure. After a new file (or directory) is added, the file (or directory) name is modified, and the file storage location is changed, the source code structure should be regenerated. Specifically, the generated source code structure includes Autoconf, automake, and other operations. The makefile. Am of each subdirectory is changed to makefile. In. Program packages with source code structure can be configured, compiled, connected, and installed using simple commands (Configure/make install) on any UNIX or Linux system.
You can execute menu operations to generate the source code structure:
[Build] → [run automake & conf]
Step 4: Configure to run configure
Configure is a script used to determine the details of the system, such as the compiler used, the library, and the location where the compiler and library are saved, and the makefile. in to form a makefile.
You can perform a menu operation to configure it:
[Build] → [run configure]
Step 5: Compile the connection
Execute the menu operation [Build] → [built project] to complete the compilation connection and form an executable file. By default, this executable file carries the source code debugging symbol.
For multi-file programs, each file must be compiled to generate the target file. After each file is compiled, the compilation connection is unified. To compile a file that is being edited separately, perform the following operations:
[Build] → [compile file]
Step 6: Run
If you wantKdevelopUnder the control of, you can run the compiled connected program to perform the menu operation:
[Build] → [excecute program]
To run the program separately, install the program first, and then enter the name of the executable file in the command line (generally, the project name.KdevelopPut the executable file in/usr/local/bin.
[Build] → [install]
Compile program files
Choose project> new project from the menu to start the new project wizard, select the project type, and specify the project name and its storage location ,. Next, click Next to create the project.
The wizard automatically generates a file containing the main function. This file is a template. You can modify and add code based on it to compile the required program.
Compile
After the program is written, you should save the file, and then generate the source code structure, configuration, and compilation following the steps mentioned above, that is, execute the following menu operations in sequence:
[Build] → [run automake & conf]
[Build] → [run configure]
[Build] → [compile file]
If each operation can be completed normally, the message "success" appears in the messages window. If no success prompt is displayed, the corresponding operation fails and the cause should be identified.
Generally, both the source code structure and configuration can be successfully generated.
If the compilation connection is performed for the first time, it usually fails, because few people can write a program without any syntax errors at a time. View the prompt information in the messages window to see where syntax errors have occurred. Click an error message,KdevelopThe cursor is automatically positioned on the statement where the error occurs.
Correct the syntax errors in the program based on the error prompt, and then try to compile again until the success prompt appears.
A common situation is that a syntax error in a program may lead to multiple error messages. Therefore, the first error message should be carefully processed, and then several errors should be randomly selected from the subsequent error information for processing. Then, the compilation attempt will be made again to check whether there is any error message. So many times, until all the error prompts are eliminated, the compilation is successful. Do not process all error messages in sequence and try to compile them. This is less efficient.
Generate executable files
After the compilation is successful, run build> built project to generate an executable file.
Debugging
Next, you can execute the menu operation build → excecute program to test run the program. This operation is performed inKdevelop. Therefore, if an "endless loop" occurs, you can choose build> stop from the menu or Press ESC to stop the program. If there is a logical error in the program, the expected results will not be obtained. It is difficult to exclude logical errors. You must carefully analyze the program to find out the cause of the error.
General logic errors can be determined based on the Running Performance of the program. Debugging tools are required for deep logical errors.
The debugging tool gnu gdb introduced earlier in this chapter is a good tool. You can use it to carefully analyze the program and find the root cause of logical errors. By default, after the build> built project operation, you can find the executable file with the source code debugging symbol in/debug/src/under the project directory.
After a logical error is found, you need to modify the program and recompile the connection. Then try again. If the expected results are still not obtained, it indicates that there are still logical errors in the program. analysis should be performed again. This is repeated multiple times until all logical errors are eliminated.
Publish executable files
If you only want to release the executable files of a program, you can adjust the compilation connection options of the project and select the optimal compilation method. In this way, you can get a smaller and faster executable file.
You can choose Project> build configuration to modify the compilation connection options. There are three options under this menu. The default value is Debug. The generated executable file contains the source program debugging symbol. You can also select default or optimized. When optimized is selected, the connection is optimized during compilation. The generated executable file is smaller and the execution speed is faster.
When debug is selected, the executable files are saved in/debug/src/under the project directory; When optimized is selected, the executable files are saved in/Optimized/src/under the project directory; when default is selected, the executable file is saved in/src/under the project directory.
If you want to publish an executable file, you should select the optimized method to compile the connection.
Publish source program
Package the project directory and all the files to form the source package. You do not need to install the source package after obtaining the package and decompressing it.KdevelopYou can compile and install them in the standard way, that is, the configure, make, make install, make clean, make uninstall and other commands are supported. This package also containsKdevelopProject files and other related information. Therefore, if you installKdevelopYou can directly open the project and modify it.
How to use existing source files?
InKdevelopThere is an automake manager tag on the right side of the main window. Click this tab to view the folder where the source file of the project is located and the files. There is a toolbar above the window with files in the column, which is used to add files. There are two ways to add files: link and copy.
Problems encountered when compiling the first program according to the above method:
A) when running run automake & friend, an error is returned:
This is because automake is not installed. The solution is to run the following code on the terminal:
B) An error occurs when running run automake & friend again:
This is because libtool is not installed. The solution is
C) Finally, the programming is passed, but an error is prompted in the excecute program:
Konsole not found
This is because konsole is not installed, and the installation is fine.
Run again and finally see the result. Close the job (* ^__ ^ *)
Sudo apt-Get install konsole
Sudo apt-Get install libtool
Macro 'am _ prog_libtool 'not found in Library
Make: *** [all] Error 1
* ** Exited with status: 2 ***
Sudo apt-Get install automake1.9
CD '/home/long/code/dev/test' & want_autoconf_2_5 = "1" want_automake_1_6 = "1" make-F makefile. CVS
Aclocal
Make: aclocal: Command not found
Make: *** [all] Error 127
* ** Exited with status: 2 ***