Thread: Importing DLL's

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    7

    Question Importing DLL's

    HI,
    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!!

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Protection of DLLs
    By Poche in forum C# Programming
    Replies: 5
    Last Post: 06-04-2009, 08:30 PM
  2. Importing DLLs
    By leorohan in forum C Programming
    Replies: 1
    Last Post: 12-30-2008, 06:48 AM
  3. Some doubts on DLLs
    By BrownB in forum Windows Programming
    Replies: 1
    Last Post: 05-30-2007, 02:25 AM
  4. standart dlls
    By keeper in forum C++ Programming
    Replies: 3
    Last Post: 07-05-2006, 07:32 PM
  5. Can't load string from resource DLL's string table
    By s_k in forum Windows Programming
    Replies: 4
    Last Post: 07-15-2003, 06:43 AM