How to use an external dll file in VisualStudio project
Date: Sep 19' 2012
by xyz
There are three approach to use the dll in our project, using '#pragma commen',
symbol '#import' or funciont LoadLibrary decleared by file <Windows.h>. But now,
we discuss the first way, and it ask we to prepare three parts of the dll: headfile,
.lib and the .dll file also. Assume we have three parts of an exsited project.
File list:
a. MyHeadFile.h
b. MyLib.lib
c. MyLib.dll
[LibraryDirectories] with File MyLib.lib path.
c. go back to left bar, find [Linker] and select [Input] in the layer list.
d. fill file MyLib.dll' name in table [Additional Dependencies].
e. select OK to save your change and quit.
in this sample , it would be #include "MyHeadFile.h", and don't forget to using macro
#pragma comment(lib,"MyLib.lib") in your main source file. After finished the whole
steps above, you can use the classes or functions that decleared and implemented in
the .dll file your just import.
by xyz
There are three approach to use the dll in our project, using '#pragma commen',
symbol '#import' or funciont LoadLibrary decleared by file <Windows.h>. But now,
we discuss the first way, and it ask we to prepare three parts of the dll: headfile,
.lib and the .dll file also. Assume we have three parts of an exsited project.
File list:
a. MyHeadFile.h
b. MyLib.lib
c. MyLib.dll
Now please open your vs solution and complete the follow steps:
-----------------------------------------------------------
a. open project's [properties]
b. select [Configuration Properites] -> [VC+ Directores], in the right Greneral page,
[LibraryDirectories] with File MyLib.lib path.
c. go back to left bar, find [Linker] and select [Input] in the layer list.
d. fill file MyLib.dll' name in table [Additional Dependencies].
e. select OK to save your change and quit.
How to use the exports class or functions in the dll file?
-------------------------------------------------------------
in this sample , it would be #include "MyHeadFile.h", and don't forget to using macro
#pragma comment(lib,"MyLib.lib") in your main source file. After finished the whole
steps above, you can use the classes or functions that decleared and implemented in
the .dll file your just import.