Boost and boost: RegEx for Linux (UBUNTU) Compilation and installation _ ershao _ Sina Blog

Source: Internet
Author: User

Boost and boost: RegEx for Linux (UBUNTU) Compilation and installation _ ershao _ Sina Blog

1. Download the boost Library
(1) HTTP download, is http://sourceforge.net/projects/boost/files/boost/1.42.0/
(2) using SVN client to download, address is: http://svn.boost.org/svn/boost/trunk/
Note: I have downloaded boost_1_42_0.tar.gz
2nd entry to the boost_1_42_0.tar.gz directory
(1) extract tar
(2) Go To The./libs/RegEx/build directory under it.
(3) make-f gcc. Mak
(4) Make-F gcc-shared.mak
Note: a gcc directory is generated under./libs/RegEx/build, which contains the most important four files:
(1) libboost_regex-gcc-1_42.a, This is the release version of the static library
(2) libboost_regex-gcc-1_42.so, This is the release version of the dynamic library (Shared Library)
(3) libboost_regex-gcc-d-1_42.a, This is the debug version of the static library
(4) libboost_regex-gcc-d-1_42.so, here the debug version of the dynamic library (Shared Library)
3. Notes for using boost RegEx libray

(1) before use, you need to add the boost installation directory to the system path (of course, you can also specify it directly during compilation)
(2) the header file boost/RegEx to be included. HPP
(3) libraries to be depended on: the four libraries compiled in the previous step can be obtained from any of them. How to Use Dynamic/static libraries, see the previous Article

(4)ProgramAfter compilation is successful, run the following command in shell before execution:Export LD_LIBRARY_PATH = "path", path is the directory where your libboost_regex-gcc-1_44.so is located, and then run your program.

My options are: Export LD_LIBRARY_PATH = "/home/yuan/software/boost_1_42_0/libs/RegEx/build/GCC"

Note:
For programming in Linux, LD_LIBRARY_PATH must be used sooner or later. However, this environment variable is based on shell, that is, it can only be used in the currently set shell, therefore, it is very troublesome to keep setting LD_LIBRARY_PATH every time you open a new shell to run the program. Therefore, we will think there is no way to do it once and for all, so that you don't need to set it again after setting it? The answer is yes, that is, in ~ /Open the. bash_profile file in the directory and set the environment variables as follows:

1. LD_LIBRARY_PATH = dir: $ LD_LIBRARY_PATH

2. Export LD_LIBRARY_PATH

However:

Ubuntu cannot set LD_LIBRARY_PATH in profile, environment, and. bashrc to solve the Library Loading Problem:
Edit/etc/lD. so. CONF file, add the specified path, or in/etc/lD. so. conf. d/Add a new configuration file to the directory. You can see the other files in the directory... Of course, you have to have the permission to do this.

So if you want to achieve this all, you can only add a new configuration file to the/etc/lD. So. conf. d/directory.

 

Note:

Ldconfig is related to running the program and has nothing to do with compiling. During compilation, you should add-L instead of obfuscation;

LD_LIBRARY_PATH is the environment variable that everyone is most familiar with. It tells loader which directories can find shared libraries. You can set multiple search directories separated by colons. In Linux, another method is provided to accomplish the same function. You can add these directories to/etc/lD. So. conf and then call ldconfig. Of course, this is globally effective within the system scope, while environment variables are only valid for the current shell.

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.