How to start reading open-source programs (eclipse) in Linux)

Source: Internet
Author: User

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 ~

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.