Latest Modification Time: 20160515
I used to write in C # often need to use this knowledge, but it was very easy to deal with, also did not pay attention to. Now start to contact C + +, at first there are many unfamiliar. Here I do not want to talk about the difference between Lib and DLL, just say how to invoke the class between each other and use it. class call between two projects
When we invoke a class under the same solution, assuming that there are two projects A and B, engineering a needs to invoke class in Project B.
First, right-click Project A to open the Properties dialog box and add a new reference to the common properties to add the B file. After that, add the header file path of Project B to the additional include directory in the general directory of C/C + + in the configuration attribute, and only add this header file path to use #include in Project A.
In theory, the above two points can be invoked. But it's not possible to call if that's what we're saying. Because the runtime prompts for the missing Lib file. This is because both of our projects generate files that are exe. If A is a startup project, then you need to change the configuration type in the project defaults in the general directory of the configuration properties in B to Static library (. lib), because only then does project B generate the Lib file under the Debug folder, and no "cannot open a Lib" error occurs at run time. classes in the project call DLL
20160515 (successful case)
Testing a lot of times, but also asked some people to know how to call, before they tried a similar method, but did not succeed.
Reference materials: MSDN Walkthrough
First of all, in the same project down with the DLL, in fact, with the static class call configuration is basically the same. You first need to add the DLL project in the common properties. Then add the header file address of the DLL file in the Include directory. It should have been done before, but I don't understand why it didn't work.
We often use the DLL is given by others, the result of their own test is, if it is to write a program or need to add a DLL file in the inclusion directory address of the header file. Also, add the corresponding LIB file in the additional dependencies of the linker's input options. At the same time, the most important point is to place the DLL and LIB files under the program folder that you write, not under Debug. But when we run the EXE inside debug, we need to put the DLL and Lib under Debug.
As for _declspec (dllexport) Such statement, you can check the relevant instructions.