28 function VS how to call the dynamic library released by others (actually similar to the previous one)

28 function VS how to call the dynamic library released by others (actually similar to the previous one)

1 The difference from the previous article
is similar. The problem I encountered in the process is emphasized here. In the previous article, when we called the implementation file, we only need to include the corresponding library directory and add library files. MyDLL2.dll operates any file path. However, here I simulated other people's package and release of the corresponding include and lib library, and found that when the dll file and .lib were put together, it reported an error, saying that the corresponding .dll file was not found.
Solution: Put the .dll file in the lib under the project path. So, you must be familiar with these issues when calling libraries released by others, otherwise you will have a headache when you deal with large projects. . .

2 Step
1) According to the previous article, generate the corresponding dynamic library files .lib and .dll.
2) Under this project, create your own include and lib files, put the header files of the above dynamic library into include, .lib and .dll into the lib file; simulate the dynamic library released by others.
Insert picture description here
3) Add the path of the calling function in the project.
Insert picture description here

4) In the project properties, follow the two steps in the previous article and add the corresponding library directory path and library file path in the project properties.

5) When generating, it turned out that it reported an error, saying that I did not have the dll file MyDll1, and I obviously put it in the lib file. . . No error was reported in the previous article, but an error was reported here.
The solution is to put the dll file in the current path of the project as mentioned at the beginning.
Insert picture description here

result
Insert picture description here

3 Conclusion So
far, in fact, it may not be understandable. Only if you do it will you know if it will work. Just generate a dynamic library according to the previous article, then package it, and copy its header files and library files to the current project. Call, which is also very important for you to encapsulate low-level functions during development.

Guess you like

Origin blog.csdn.net/weixin_44517656/article/details/108174252