Linux publishing programs under different machines

Source: Internet
Author: User

In the native Linux environment compiled well, can be run on this machine, but due to the field installation, the program directly copied past, found that the program run error. For example

/usr/lib/libstdc++.so.6:version ' glibcxx_3.4.9 ' not found
/usr/lib/libstdc++.so.6:version ' glibcxx_3.4.11 ' not found
/lib/libc.so.6:version ' glibc_2.7 ' not found (required by/usr/lib/libcrypto.so.10)

Use the command LDD to view the library files that the program depends on:


We can see that these library files are under the/lib/path, especially ld-linux.so.2, where the ld-linux.so.2 determines the default path of the program lookup Library. Other machines also have these libraries, but the program does not run because of the library file version. If we copy these libraries to other machines, the program relies on these versions of the library and there is no problem. So we can do this:

(1) Copy these library files to a new folder under/home/dynamic/.

(2) then modify the Makfile file,makefile g++ compile option Finally, add the following options to specify the dynamic library's preferred search path and dynamic linker:-wl,--rpath=/home/dynamic/-wl,-- Dynamic-linker=/home/dynamic/ld-linux.so.2, recompile. Using the LDD command to view the compiled program, you can see that the path to the dependent library file has been modified.

(3) If you deploy the program to another machine, create a new/home/dynamic/on the other machine and copy the library files that were just on the compiler's machine to the past. So the program will work.

You can also refer to the article http://tech.ddvip.com/2013-11/1384435922205976.html


Linux publishing programs under different machines

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.