Today, I finally found a method and wrote it down.
After getting an open-source project, how can we start, how can we quickly debug and track methods to read the program? Today, I finally found some tips and wrote them down.
Read the debugging environment in eclipse
1. Install the open source project
During installation, you should note that the installation is Debug. This directory is generally installed in your learning directory.
For example:./configure -- prefix =/home/godpig/study/opensrc -- enable-Debug
Then make and make install
At this time, there are already installed programs under the/home/godpig/study/opensrc directory, including subfolders such as include and Lib.
During development, include is the directory of the header file to be included, and Lib is the development library.
2. Open eclipse and create a helloworld project.
Write a simple code to call this open-source project and save it as helloworld. C. You can also find example directly from the open-source project.
Configure the environment
Right-click the current test project and choose Properties> C/C ++ build> Settings.
In this case, in the right tab, the first tab is: Tools setting by default.
Toos setting-> GCC compiler-> directories Add the include directory, that is,/home/godpig/study/opensrc/include
Toos setting-> GCC linker-> Libraries add the library directory in the library search path:/home/godpig/study/opensrc/lib. Add the library to be linked to libraries, for example, opensrc. At this time, libopensrc. A is automatically searched. (But I have a problem here. You need to manually add the link option-lopensrc after the GCC command in the command of GCC linker)
In this way, the header file is automatically searched from the include file, and the library is automatically searched in Lib.
3. Start single-step debugging
At this time, the helloworld can be compiled, and the link can be compiled successfully.
If the program cannot be executed through debug, opensrc may not be found. so and other errors. This may be your lib directory, that is,/home/godpig/study/opensrc/lib is not in the LD_LIBRARY_PATH environment variable of the system, dynamic libraries cannot be automatically loaded. (If you do not use -- prefix to specify a custom directory during installation, this problem will not occur)
If opensrc. So is not found, you need to modify the LD_LIBRARY_PATH of the system or configure the debug environment variable in eclipse.
The method is as follows:
Click the debug icon, and there is a debug configurations-> environment-> New
Use LD_LIBRARY_PATH as the name,/home/godpig/study/opensrc/lib as the value, and save
At this time, we can perform one-step debugging. Everything is okay ~