I've just begun dabbling in this aspect of C and I was wondering if there was any hard and fast way of importing a DLL in to another C-program?? When I compile the DLL it produces a *.a and a *.def file(using mingw compiler). Do these files have to be any where specific?
If anyone could gimme a quick and easy few steps to importing a library in to a program it would be great!!
Never used Mingw to create a Dll, but usually there are 2 ways of using the dll
- 1 - Implicit Linkage - You use the import library created from your dll project (usually a .lib file, maybe the .a file in your case), and add it to the app that you want to use with the dll. When you then link this program, info will be added to your .exe's import table to load your dll and resolve the addresses to the functions you wish to import. You need to declare these imported functions as you would any other external function (use the "extern" declaration)
- 2 - Explicit Linkage - Your .exe's code calls LoadLibrary() to load your dll......then with the handle this function returns, call GetProcAddress() to locate the exported function. You need to declare a typedef function to allow your compiler to call this func