I am trying to create an application in visual studio that will be able to access a .dll file that already exists. I need the application to call up routines. I also have a header file that already exists.
I have been researching on the internet and have found that I need to create a .lib file. Looking at similar questions on here I found a link: http://support.microsoft.com/kb/131313 I cannot however follow the directions.
The information in the link says to make a DEF file ( I read elsewhere that this needs to be compiled as a DLL with the same name, but not sure what that name is, the same name as the .dll file?). But I do not understand the first direction, to 'Use DUMPBIN /EXPORTS'. I then need to 'stub out' functions, and then something to do with .OBJ files (I do not know what these files are).
Are there any step-by-step directions, similar to the link above, that are easy to follow?
You can use Digital Mars's IMPLIB tool. It can create a lib file using only the dll, without any need for a .def file.
The download link is http://ftp.digitalmars.com/bup.zip.
The command line is:
Instead of creating .def, you can create .lib file from .dll file by exporting the functions / classes defined in the .dll file by __declspec(dllexport) which were referred in the application code.
For example (Pseudo code)
PROJECT for creating X.dll file (say, X is a dll name):
A.h:
A.cpp:
If you build the above dll project in Visual Studio then the compiler will generate X.dll and also X.lib [which has exported function foo by __declspec(dllexport) ].
App.cpp:
For further study please refer the following links for better understanding:
http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL#CppMatureApproach
http://msdn.microsoft.com/en-us/library/ms686923(v=vs.85).aspx
You're going to need Microsoft Visual C++ 2010 Express (or any other source of MSVC command line tools), and your DLL.
Steps:
dumpbin /EXPORTS yourfile.dll > yourfile.exports
yourfile.exports
into a newyourfile.def
file. Add a line with the wordEXPORTS
at the top of this file.VC\bin
directory (the one wherelib.exe
and other compile tools reside).You should get two files generated:
yourfile.lib
andyourfile.exp