About Auto-linking

Source: Internet
Author: User
Tags visual studio 2010

The environment discussed below is based on Visual Studio 2010.

In the process of using OPENCV, we not only specify the header file and library directory, but also specify the name of the library, for example, in order to use common basic functions, we need to specify additional Libopencv_highgui249.dll.

In contrast, in the process of using the C + + Boost Library, we only need to specify the directory and library directory of the header file, and we do not have to specify additional dependencies (that is, the name of the specified library). If we include the BOOST/TIMER/TIMER.HPP header file and use the/MD compile option, Boost will automatically link the libboost_date_time-vc100-mt-1_57.lib to us. This process is called auto-linking.

In Wikipedia, here's what auto-linking says:

auto-linking is a mechanism for automatically determining which libraries to link to while building a C, C + + or O Bj-c program. It is activated by means of #pragma comment (lib, <name>)statements in the header files of the library, or c3> @import <name> depending on the compiler.

Most Windows compilers support auto-linking, as does Clang, while GCC does not support auto-linking< /c5> [1]

Most Windows compilers support auto-linking, and GCC does not support auto-linking. So in the GCC environment, we probably have to specify additional dependencies (the library name) ourselves.

In the boost documentation, we can find a description of auto-linking:

Auto-linking

Most Windows compilers and linkers has so-called "auto-linking support," which eliminates the second challenge. Special code in Boost header files detects your compiler options and uses, information to encode the name of the Corr ECT library into your object files; The linker selects the library with this name from the directories you ' ve told it to search.

The GCC toolchains (Cygwin and MinGW) are notable exceptions; GCC users should refer to thelinking instructions for Unix variant OSes for the appropriate command-line options to use.

The second challenge here means a task that specifies the name of the library.

Since there is special code in the Boost header file (which I think is probably some #pragma comment (lib, <name>), we do not need to specify the name of the library ourselves, Linker will find itself in the library directory we specify.

Of course, it also says that the GCC toolchain is a notable exceptions.

About Auto-linking

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.