How to use macros from a C + + dynamic library with a static library

Source: Internet
Author: User

In which CPP file the dynamic library or static library is used, the macro in the library is added to the preprocessing command for the project where the H/cpp file resides.

If there is a library project add, its header file is as follows

#ifndef _add_h #define _add_h#if defined (_WIN32) | | Defined (__mingw32__)#   if  defined (add_exports) #       define Add_export __declspec ( dllexport) #   | | ! defined (add_use_static_lib) #       define Add_export __declspec (dllimport) #   else#       define add_export#    int Add (intint  b); #endif

When you compile a dynamic library on VS, you need to add add_exports to the preprocessor directives in the Add Project.

Another test project: if it is going to use the ADD function in a dynamic library, it needs to use the Add_use_dll_import preprocessing directive in its engineering.

How to use macros from a C + + dynamic library with a static library

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.