Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++ - how to refer a header file which is used in a dll while loading thru loadlibrary method

C++ - how to refer a header file which is used in a dll while loading thru loadlibrary method

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++tutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DavJes
    wrote on last edited by
    #1

    Hi I m trying to load the dll using LoadLibrary which works fine. But for one of the method paramter is an object of class which is refered inside the dll . So in this case in my client app how do i refer the .h file which is already refered in the dll inside ? As i m trying to link dynamically how does header file references are dealt with ? Thanks

    H CPalliniC S 3 Replies Last reply
    0
    • D DavJes

      Hi I m trying to load the dll using LoadLibrary which works fine. But for one of the method paramter is an object of class which is refered inside the dll . So in this case in my client app how do i refer the .h file which is already refered in the dll inside ? As i m trying to link dynamically how does header file references are dealt with ? Thanks

      H Offline
      H Offline
      Hans Dietrich
      wrote on last edited by
      #2

      When you want to call a function that is in a DLL - whether it is dynamically loaded or not - you must tell the compiler what the function parameters are. The is what the .h file does.

      Best wishes, Hans


      [Hans Dietrich Software]

      1 Reply Last reply
      0
      • D DavJes

        Hi I m trying to load the dll using LoadLibrary which works fine. But for one of the method paramter is an object of class which is refered inside the dll . So in this case in my client app how do i refer the .h file which is already refered in the dll inside ? As i m trying to link dynamically how does header file references are dealt with ? Thanks

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        See if this[^] helps. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        • D DavJes

          Hi I m trying to load the dll using LoadLibrary which works fine. But for one of the method paramter is an object of class which is refered inside the dll . So in this case in my client app how do i refer the .h file which is already refered in the dll inside ? As i m trying to link dynamically how does header file references are dealt with ? Thanks

          S Offline
          S Offline
          Stefan_Lang
          wrote on last edited by
          #4

          You repeatedly use the term 'refer', but didn't really clarify at which point you have trouble making the connection between your application and the DLL - it could be at compile time, at linking time, or at run time: 1. compiling Any parts of the DLL that you are supposed to use from outside have to be declared in header files, using the 'extern' keyword. These header files then have to be included in the application that wants to use the DLL. This is neccessary for the compiler to understand the format of the function calls and the types of the parameters and return values. 2. linking Once your application is successfully compiled, the linker will try to resolve the function calls into the DLL. This requires information about the already compiled DLL, which is contained in a file called '.lib'. You have to specify this Lib file (and possibly it's path) in the linker options. With the help of this Lib file, the linker will look up the offset of the function within the DLL and encode this into the function call. 3. running At run-time your application will eventually call the LoadLibrary function that you specified. Provided the DLL can be found at the same location as your application is, or else, if you provided a path, at that path's location, the DLL will now be loaded into memory. When your code runs into a DLL function call, the system will use the linker-provided offset to invoke the correct function within the DLL.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups