views:

193

answers:

1

I am facing the the problem to link to a third party dll. It is windows mobile application, where I am try to link to this third party dll.

Here first I had the dll and lib file. I was not able to link to it explicitly, but implicit linking is working. In the explicit linking the getprocaddress was failing. The dumpbin showed only the dllmain functions being exposed and no other function being exposed, hence the getprocaddress was failing. However my application doesnot start if the dll is not found/installed in the device. It is expected as it is imlicit linking of a dll hence my application does not start.

I reported this to the third party dll provider and said that I want the explicit linking as the dll takes more space in my application if it is linked implicitly. They replied by providing the .def file and said that I can use this .def file in my app to explicitly link to a dll.

I don't know how to use this .def file to explicitly link to a dll. Can any one please explain briefly about how to use this .def file in my app to explicitly link to a dll.

+1  A: 

Use the *.def file when you build the DLL, to specify what function names the DLL is supposed to export.

After the DLL is built, use dumpbin /exports to verify that the functions are indeed exported from the DLL.

After you have verified that the DLL is exporting functions, you can either link to them at run-time using LoadLibray/GetProcAddress, and/or you can link to them at build-time by passing the DLL's *.lib file (which was created when you built the DLL using its *.def file) as an argument to your application's linker.

ChrisW
Hi chrisW, I dont have the source files to build the dll, I only have the dll, lib and the coresponding .def file provided by the third party.
You said, "The dumpbin showed only the dllmain functions being exposed and no other function being exposed, hence the getprocaddress was failing." If other functins aren't being exported then I don't think you can link to them even with a *.def file. The O/S's run-time loader (which does the dynamic linking) wants to work with functions which the DLL has exported.
ChrisW