Migration Library needs considerations (how to use files generated with the migration library)

Source: Internet
Author: User
Tags mathematical functions
porting libraries requires considerations (how the files generated by the migration Library are used)

General induction of the migration of simple libraries

1. File location After migration general Select a new folder under the opt/directory, such as Opt/lib-codec

2. Configuration options typically require the identification of compilation tools and link Tools , as well as the end of the CPU and OS that declares the compilation environment and the migrated libraries, and also the location of the files that are generated after the library is compiled. Like what:

./configure CC=ARM-LINUX-GCC ld=arm-linux-ld--prefix=/opt/lib-codec--exec-prefix=/opt/lib-codec
 -- Enable-shared--enable-static-build=i386-host=arm-linux
--prefix=  Specifies the compiled dynamic library. So, Static library. A, header file. h storage location (before configuration to determine if directory is present)
--exec-prefix= Specify the location of the executable file
--enable-shared= : Enable sharing, guess generate dynamic link library.
so--enable-static=: Enable static, guess generate static link library. A and header files. h
-build=: Settings for the compilation environment
-host=: Run environment CPU and system settings

3. Sometimes you need to set up a corresponding directory, such as the Include directory Lib directory, and so on, specifically need to check the specific options in Makefile, General Xxxdir variable value is the directory to be established

4. The purpose of the transplant is to get three things from the Source: dynamic library. So, Static library. A, header file. h. The following examples illustrate the use of dynamic-link libraries

Transplant well. h is located in Opt/lib-codec/include;.so and, a file is located in Opt/lib-codec/lib Deployment: Dynamic link library. So files are placed in the appropriate directory on the Development Board, usually in the/usr/lib directory

The CP copy uses the '-a ' or '-d ' option to retain the link. The '-a ' option is typically used when copying a directory, preserving links, file attributes,
and recursively copying the directory, which is equal to the combination of the DPR option
The compilation parameters in the project configuration 1:makefile are being written cflags add the corresponding header file path
CFLAGS + =-I $ (shell pwd)/include-i/opt/lib-codec/include
Writing project configuration 1: Link parameter ldflags Add the path to the appropriate link library (that is, the location of the function entity declared in the. h file)
CFLAGS + =-I $ (shell pwd)/include-i/opt/lib-codec/include
ldflags: =-ljpeg-l/opt/lib-codec/lib
-L is a link option (ldflags), used to specify links to additional libraries (such as the use of mathematical functions, with-LM, the linker will go to link libm.so
then we use the Libjpeg, The corresponding library name is called libjpeg.so, you need to use the-LJPEG option to link)
-l is the link option (specified in ldflags), used to tell the linker to which path to find the dynamic link library.
Example:   Ldflags: =-ljpeg-l/opt/lib-codec/lib
Summary:-L is the name of the dynamic library that tells the linker to link, and-l is the path that tells the linker library (with use)

Note the path to the dynamic-link library that is required to compile the linker and the path to the dynamic-link library when the program runs with dynamic links

Note 1: Configuring the content of the generated makefile can help you understand

Note 2: Sometimes, some libraries do not support certain configuration options, such as./configure CC=ARM-LINUX-GCC ... will tell you not to support, how to do? Use the Export command for temporary exports:

Export CC=ARM-LINUX-GCC

Note 3: Sometimes porting a library needs B library support, B library after the transplant to continue a library, found or error: Xxxlib not installed. The reason is because the relevant environment variables are not exported, so the a library can not find the configuration of the library files and header files of the B library just migrated, the solution is to use epport temporary export

# export ldflags= "-l/opt/lib-codec/lib"  ; b Library dynamic link and static link file
# export cflags= "-i/opt/lib-codec/include"; b Library header File
# export cppflags= "-i/opt/lib-codec/include"

Attached: More detailed content can be accessed to help understand
Imageplayer Open Source Library for development diary use
Imageplayer Development Diary of Libjpeg transplant
Imageplayer Development Diary of Libpng transplant

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.