loading .h, .dll, and .lib

This is a discussion on loading .h, .dll, and .lib within the Windows Programming forums, part of the Platform Specific Boards category; Hello everyone. n00b alert! This might sound like an insult to your intelligence, but I'm just clueless on how to ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    2

    loading .h, .dll, and .lib

    Hello everyone. n00b alert!

    This might sound like an insult to your intelligence, but I'm just clueless on how to do it.

    Here are the "files" that I have:
    somefile.h
    somedll.dll
    somelib.lib

    Basically I have a header file, dll file and a lib file. The only info I have is whatever is in the header file. Seems like just constants and function declarations.

    That's pretty much all the info I know. How would I know what's inside the dll file? From my understanding of DLL's, they are just a compilation of functions. As far as the LIB file, I have no idea what's in it.

    My question is, what do I do with these files? I can include the header file, but then I'm stuck after that point. I don't know what else I'm suppose to do.

    I have a .cpp file in which it includes somefile.h. Don't really know how to proceed after that.

    I have DevCpp that I just downloaded and currently use. I do have access to VC++ 6.0 that my friend gave me for free, but I'm not sure if I want to install it. I would like to get this working (or make it do something) using DevCpp if possible.

    Thank you in advance.

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    What you have is a compiled DLL project. You link the .lib, which handles run-time loading of the DLL for you. You include the .h file in yoru prject so that yoru code knows how to access the stuff in the DLL. As far as finding out what functions are in the DLL, their prototypes shoudl be in the .h file.

    VC++ 6.0 is better than dev-cpp IMO. I've used both and Visual Studio has a much better IDE as far as im concerned. If you have both alread I'd recommend switching to VC.
    Last edited by abachler; 02-07-2008 at 03:33 PM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    Visual Studio Express is also free, so if you want to use Visual Studio, I recommend you upgrade because VC6 is quite old.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    2
    Thanks guys for the response. I'll look into Visual Studio Express.

    Anyone willing to post in advance on how to link the .lib file and how I load the DLL file?
    It's something I'm sure I'll end up asking anyway.

    I just now took a look at the header file.

    Could someone kindly tell me the purpose of extern "C". I'm guessing specific to C instead of C++?
    There's also a __declspec(align(1)) followed by a stuck. What bothers me is that it doesn't have a semicolon after it. Not sure if this is a typo and might trigger the debugger.
    Code:
    extern "C"
    {
      __declspec(align(1))
      struct ....
      ...
    }
    Thanks guys and sorry for the questions. This is just more advanced than the "Hello World!" program that I've mastered. Never had to deal with DLL and LIB files before.

  5. #5
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Anyone willing to post in advance on how to link the .lib file and how I load the DLL file?
    It's something I'm sure I'll end up asking anyway.
    1.You include h file in you code as you include for example <cstdio>
    2. You add the lib file to your linker inputs list - something like "additional libraries"
    3. you put dll in some folder that is available to the system - or in the folder where the exe is located, or in folder that is listed in the PATH environment variable.

    this should to the work

    Could someone kindly tell me the purpose of extern "C".
    So the functions could be called both from C and C++ code

    There's also a __declspec(align(1)) followed by a stuck. What bothers me is that it doesn't have a semicolon after it. Not sure if this is a typo and might trigger the debugger.
    no it should not be. it is some modifications to the struct type. It tell the compiler to make 1 byte alignment of members, preventing adding any padding between members of the struct.
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to properly use a .lib file?
    By Kurisu33 in forum C++ Programming
    Replies: 6
    Last Post: 09-28-2006, 08:19 PM
  2. possible to link and run with .lib file without .dll file?
    By George2 in forum Windows Programming
    Replies: 1
    Last Post: 05-25-2006, 09:05 PM
  3. .h and .lib unloader
    By Killhard666 in forum C++ Programming
    Replies: 5
    Last Post: 09-19-2005, 10:20 PM
  4. Compile Program missing .lib file have .dll
    By John Hobbes in forum C++ Programming
    Replies: 1
    Last Post: 11-19-2004, 04:52 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