C++ - how to refer a header file which is used in a dll while loading thru loadlibrary method
-
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
-
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
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
-
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
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] -
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
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.