Rookie Advanced: VC + + in Visual Studio DLL call implementation [static embedding]

Source: Internet
Author: User

C + + Write DLL, in C + + call is actually a relatively simple thing, call DLL function method In fact there are many, say one of the most common method:

1. Create a new solution, file--New project->visual C++->WIN32 Console application->next->dll-> complete.
2. Static (. lib), configuration type, project properties.
3. lib2.h File:

Class Lib2 {public: Lib2 (); ~lib2 ();  int calc (int val2);};      

4. lib3.cpp File:

"stdafx.h""lib2.h"lib2::lib2 () {}lib2::~lib2 () {}int lib2::calc (int val2 ) {return val1 + val2;}           

5. Build the solution

6. Create a new Visual Studio, create a new->visual C++>WIN32 console Application->next-> console application->next->finshe.
7, the->c++ directory in the project properties, including the directory where the directory is added lib2.h. Library directory Select the directory of DLLs and LIB, typically the debug directory under LIB2 solution.
8, additional dependencies, input, linker, item properties, and so on, add to Lib2.lib
9,

"stdafx.h"#include <iostream>#include <lib2.h>int main () {lib2* lib=new  LIB2; int result = Lib->calc (6"Result:" << result << Std::endl;  0;}               

10, F5 operation can be.

Rookie Advanced: VC + + in Visual Studio DLL call implementation [static embedding]

Related Article

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.