Linking a DLL

This is a discussion on Linking a DLL within the C Programming forums, part of the General Programming Boards category; Hi, I'm very new to making use of 'open source' libraries in my C programs. I'm currently trying to use ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    7

    Unhappy Linking a DLL

    Hi,

    I'm very new to making use of 'open source' libraries in my C programs. I'm currently trying to use the GD graphics library. This library can be used by linking my program to a dll. Forgive me if this is a stupid question, but how do I go about linking my program to the dll? Is it done in the c source code or do I have to tell my compiler (Digital Mars) to do it?

    Thanks for any help you guys may be able to offer,

    T

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    In general you can not link to a dll. You need to have a library to make the linker happy. Usually compilers allready install import-libraries for all kind of system-dlls. If you don't have an importlibrary for a certain dll there is usually some tool that comes with your compiler that allows you to generate such an import library from the dll and some definition-file ( or the header ).
    Another possibility is to explicitly link to the dll by calling OS-functions like loadlibrary() and GetProcAdress() at runtime.
    Kurt

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    7
    Thanks. Also supplied with the dll was a ".a" file and this is in the documentation:

    'users can simply link with the provided libbgd.a stub library in order to use the DLL'

    Is there a C function I can use to link to this 'stub library'?

  4. #4
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    You have to add that library to the linker options of your build-tool. usually some option like -lbgd in your case.
    sorry don't know about Digital-Mars.
    Kurt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linking to my own DLL
    By yahn in forum C++ Programming
    Replies: 19
    Last Post: 10-13-2008, 07:59 PM
  2. resources on linking to a dll
    By Luciferek in forum C++ Programming
    Replies: 4
    Last Post: 07-30-2008, 11:22 AM
  3. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 02:20 AM
  4. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM
  5. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 04:29 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21