Calling exported functions from a static DLL
-
I have a x.lib and x.dll. its a static dll. Now i am using functions exported in this dll by loading this dll and calling functions thro GetProcAddress API. Now i don't want to load dll instead i want to use x.lib, Please let me know how i can call those functions by using x.lib
-
I have a x.lib and x.dll. its a static dll. Now i am using functions exported in this dll by loading this dll and calling functions thro GetProcAddress API. Now i don't want to load dll instead i want to use x.lib, Please let me know how i can call those functions by using x.lib
I think you may have your terms a little confused so I'm not exactly sure what you want. There are basically three scenarios: 1. x.dll is a Dll and is used by calling LoadLibrary and GetProcAddress 2. x.dll is a Dll, x.lib is its import library. x.lib is linked into application y which is then implicitly linked to x.dll. x.dll get loaded by y.exe during the bootstrap phase and functions in x.dll can be called directly from y.exe code, No LoadLibrary, no GetProcAddress 3. x.lib is a static library which is linked as part of y.exe. The two are merged at compile time to produce y.exe. That's it, the functions all act as if they are in the same module because they are, no LoadLibrary, no GetProcAddress Generally you'd use: 1 if the code in x.dll is shared and only used occassionaly by y.exe 2 if the code in x.dll is shared and used all the time by y.exe 3 if x.lib is really just a subdivision of y.exe and is not used by other applications. I hope this helps. :)
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
-
I have a x.lib and x.dll. its a static dll. Now i am using functions exported in this dll by loading this dll and calling functions thro GetProcAddress API. Now i don't want to load dll instead i want to use x.lib, Please let me know how i can call those functions by using x.lib
To complete what Matthew just said, if you are in scenario 2 (x.lib is the import libary of the dll), then you can't statically link to it to access the functions. The lib doesn't contain the code for the functions but only information about how to load the dll.
Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++ -
I have a x.lib and x.dll. its a static dll. Now i am using functions exported in this dll by loading this dll and calling functions thro GetProcAddress API. Now i don't want to load dll instead i want to use x.lib, Please let me know how i can call those functions by using x.lib
Yashusid wrote:
its a static dll
impossible.
DLL
means**D**YNAMIC **L**ink **L**ibrary
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
I think you may have your terms a little confused so I'm not exactly sure what you want. There are basically three scenarios: 1. x.dll is a Dll and is used by calling LoadLibrary and GetProcAddress 2. x.dll is a Dll, x.lib is its import library. x.lib is linked into application y which is then implicitly linked to x.dll. x.dll get loaded by y.exe during the bootstrap phase and functions in x.dll can be called directly from y.exe code, No LoadLibrary, no GetProcAddress 3. x.lib is a static library which is linked as part of y.exe. The two are merged at compile time to produce y.exe. That's it, the functions all act as if they are in the same module because they are, no LoadLibrary, no GetProcAddress Generally you'd use: 1 if the code in x.dll is shared and only used occassionaly by y.exe 2 if the code in x.dll is shared and used all the time by y.exe 3 if x.lib is really just a subdivision of y.exe and is not used by other applications. I hope this helps. :)
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
I think the 2) option does work for me. i will clarify my doubt again, please confirm whether 2) option works or not. I have some code x when built it gives x.dll and creates x.lib. Currently i m loading x.dll by LoadLibray and calling function thro' GetProcAddress. Now i want to call those same functions but want to avoid using LoadLibray and GetProcAddress. How it could be done ?? Thanks a lot !!!!
-
I think the 2) option does work for me. i will clarify my doubt again, please confirm whether 2) option works or not. I have some code x when built it gives x.dll and creates x.lib. Currently i m loading x.dll by LoadLibray and calling function thro' GetProcAddress. Now i want to call those same functions but want to avoid using LoadLibray and GetProcAddress. How it could be done ?? Thanks a lot !!!!
-
I think the 2) option does work for me. i will clarify my doubt again, please confirm whether 2) option works or not. I have some code x when built it gives x.dll and creates x.lib. Currently i m loading x.dll by LoadLibray and calling function thro' GetProcAddress. Now i want to call those same functions but want to avoid using LoadLibray and GetProcAddress. How it could be done ?? Thanks a lot !!!!
OK, you need to add x.lib to the Input files list for the Linker. I'd need to know what development environment you're using to be much more specific. Your exe source files which call functions in the dll will need to include the relevant header file from the dll source e.g.
//exe_main.cpp #include "mydll.h" int iResult = MyDllFunction( "SomeString" );
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
-
OK, you need to add x.lib to the Input files list for the Linker. I'd need to know what development environment you're using to be much more specific. Your exe source files which call functions in the dll will need to include the relevant header file from the dll source e.g.
//exe_main.cpp #include "mydll.h" int iResult = MyDllFunction( "SomeString" );
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
-
In which case, as you probably know, you'll find the Linker Input files by right clicking on your project (not the solution), selecting Properties and then choosing Configuration Properties\Linker\Input in the properties dialog. You can add the name of your x.lib file to the 'Additional Dependencies'
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
-
In which case, as you probably know, you'll find the Linker Input files by right clicking on your project (not the solution), selecting Properties and then choosing Configuration Properties\Linker\Input in the properties dialog. You can add the name of your x.lib file to the 'Additional Dependencies'
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)