C ++ configuration of eclipse in Linux

Source: Internet
Author: User

Turn: http://blog.csdn.net/schumyxp/article/details/2119186

I plan to use eclipse in Linux for C ++ development. Because I haven't done c ++ development for a long time and I am not so familiar with Linux, I will record my getting started experience.

The purpose is to create a shared library and call it with another project.

First, create a shared library. Open eclipse, select the shared library in the C ++ project, create it, and then write the correspondingCodeSomething ......
For example, this library is called test, which contains a class called ctest.

After writing the code, compile it to ensure that there is no problem. At this time, we should get a libtest. So file, and the header file ctest. H of the ctest class.

At this time, this library cannot be used directly as in windows. You still have to perform "installation ".

In fact, this library can be installed in many places. I installed it under/usr/lib. But there are a lot of things in the system. In order not to confuse my library with the system, I created a folder named cLib under/USR and copied libtest. So and ctest. h to/usr/cLib.
Create a soft link as follows:
# Ln-S/usr/cLib/libtest. So/usr/lib
After the system is created, update the system information:
# Ldconfig
Then, the database can be used. The shared libraries in Linux are like DLL with a strong name in. net.

You can use this library below. However, it is troublesome to use C ++.

First, create an executable C ++ project, and then "introduce" the library just installed. The introduction process is as follows (. net just a few clicks below, all spoiled me ):

Specify the path for the compiler: Under the-l parameter, add the location of libtest. So. Here is/usr/cLib.

Specify the library to be referenced for the linker: Add test under the-l parameter, which is the shared library previously created. Both lib and. So before and after test are added by the system, and will be added by the system during compilation, so you must write test.

Specify the path of the library for the compiler: Under the-l parameter, add the path of libtest. So. Here it is still/usr/cLib.

After this configuration, the test database can be used.

When used, after include "ctest. H", you can use the class ctest.

If you are afraid of chaos, put the header file ctest. h under the/usr/cLib/ctest directory, that is, include "ctest/ctest. H. Now I should understand it better. In the future, I can make full use of the file structure.

Next, you can compile and runProgram.

If something goes wrong unfortunately (it is estimated that many of the people who are engaged in Linux development for the first time will go wrong), don't worry, almost all of them are not correctly written in the above path. At this time, you can use the LDD command to check the databases referenced. If there is any problem, you can see it at a glance.

I think with these basic preparations, you can start C ++ development in Linux.

 

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.