Thread: Dll

  1. #1
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735

    Dll

    How do I make it so when my project's header is included, it will make the recipient project know that their is an accompying DLL? For example when you include SDL.h in a project it automatically knows about SDL.dll. Also, my project is an .h and a .dll. Most projects have .libs, .h and .dll. What's the lib for and how do I make one?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    libs are for statically (compile-time) linking object code whereas dlls are for dynamic (run-time) linking. compilers like vc++ and dev-c++ allow you to create projects for both, but you can also find independant tools out there that can generate them from obj files. a search engine would be a good starting point to find out all the options to you.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    The dll projects I compile with Microsoft compilers produce both a dll and a .lib. The application program links with the .lib to resolve the external references contained in the dll. Then the application program just calls the functions contained in the dll as if they were part of the application. Most microsoft dlls work that way.

    There is another way to accomplish that without the .lib, but its a little more complicated for the application program -- see MSDN for win32 api function LoadLibrary().

    Visual Studio 2003/2005 compilers have yet another method for managed c++, but I haven't started learning that yet, and probably won't for several more years.
    Last edited by Ancient Dragon; 03-11-2006 at 08:29 PM.

  4. #4
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Thanks, so but how do I make it look for the dll the normal automatic way? (not LoadLibrary)

    And how do I need to declare the functions so that a lib will be created?

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> Thanks, so but how do I make it look for the dll the normal automatic way?

    that depends on the compiler you're using - you'll need to look the documentation.

    >> And how do I need to declare the functions so that a lib will be created?

    a lib is simply a file format that contains multiple obj files. again, how to generate the lib and how to access the functions in it will depend on your compiler.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  6. #6
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    >>Thanks, so but how do I make it look for the dll the normal automatic way? (not LoadLibrary)

    When your program starts, MS-Windows os looks for the dll in either your program's startup directory or in one of the directories in the PATH environment variable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  2. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 02:20 AM
  3. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM
  4. Using class with DLL
    By greg2 in forum C++ Programming
    Replies: 2
    Last Post: 09-12-2003, 05:24 AM
  5. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 05:29 AM