Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have static libary, which I am using in C++.Net. It was working fine. But now because of some issues I wanted to load libary at runtime (previously I was adding lib file path to Additional Dependencies in Project settings). So, without adding to 'Additional Dependencies' can I use it, without changing my code.

I tried use LoadLibrary API, but, as obvious I am getting lots of unresolved externs errors.

Happy Programming.
Posted
Comments
ThatsAlok 26-Jun-12 3:20am    
you might have remove reference of older lib file and kindly let people know how you creating function pointers?

When using LoadLibrary you must use GetProcAddress to retrieve the address of each used function and call that function using the returned address (see Using Run-Time Dynamic Linking [^]).

If the issues are using functions that are not supported by all Windows versions, you may link DLLs delayed and call those functions only when the Windows version requirements are met (see /DELAYLOAD linker option[^]).
 
Share this answer
 
If you really have a static library, you can't load it at run-time. Static libraries are linked in at compile/link time - that's why they're called "STATIC LIBRARIES".

On the otherhand, if it's a DLL (Dynamic Link Library), then you could load at run time using LoadLibrary and GetProcAddress.

Good luck.
 
Share this answer
 
Comments
Vitaly Tomilov 25-Jun-12 14:14pm    
I believe the author of the question is confused. There is no such thing as static C++ library in managed C++, it only exists in unmanaged C++.
you can see more GetProcAddress infomation about
"http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212(v=vs.85).aspx"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900