Got stucked in C + + Static Library Loading. For some time

Source: Internet
Author: User

I used to the load library using 1 single. dll file, so if I happen to does method calling between 2 projects in a solution, I Got puzzled.

In the solution, doing method calling between projects are constant, so as far as I can see, the dynamic calling method is Onerous. It's also not Okay to call method from the other project directly, which would invoke the unresolved external l Ink error (2001,1014,2011, etc..) During link.

Eventually I found that static calling is the remedy. In the This is the avoid doing onerous calling that dynamic calling might cause. But the shortcoming was to attach a. Lib with the release, making the size larger. Most times. lib files is small in size.

Dynamic calling in x86 programs:

1 // method definition in. dll:type Func (type1 t1, type2 T2); 2 typedef type (*F) (type1,type2); 3 New LoadLibrary (". dll"); 4 f = GetProcAddress (5        hInst,6         "Func"7 }; 8 // method name never coincides.

Static calling:

1 //statically calling Method2 //First , specify the additional/C + + include directory where func.h is an in C + + general from project properties.3 //Second, if needed, specify the func2.lib file directory in link general from project Properties4 //func.h5#include "Func2.h"//This file contains the function definition6#pragma comment (lib, "Func2.lib")//. lib file contains info about method addresses in. dll file7Func2 ();//Method Calling

Got stucked in C + + Static Library Loading. For some time

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.