Answered by:
DLL and libs

Question
-
I`m trying to build a dll library which uses third party libraries (i have an option to use static or dynamic linking with those 3rd party libs). When my main project builds it always looks for those 3rd party dependencies (i don`t use any of the calls from 3rd party libs in my main program). I managed to build main program but i added those dependencies in main program. Is there some way to shield my main program from those 3rd party dependencies and to include them directly in dll i`m building so my main program is not aware of what dll or libs are used in dll implementation?
main program <- my dll (i`m building) <- 3rd party lib or dll
<- uses
- Edited by msforenter090 Thursday, March 24, 2016 10:18 PM
Thursday, March 24, 2016 9:16 PM
Answers
-
Thanks for the help i solved the problem.
It requires little macro managing.
main pragram <- My DLL(.h, .lib, .dll) <- 3rd party (.h, .lib)
Since main program include .h from My DLL and .h from My DLL includes .h from 3rd party lib i
added conditional macro inclusion in .h file from My DLL. Something like this#ifndef USE_MY_DLL
#include <ThirdPartyLibHeader.h>
#endifIn this case main program has to define the USE_MY_DLL in order to use the DLL.
If main program does not define the macro linker will complain about missing header file.Saturday, March 26, 2016 12:36 PM
All replies
-
Yes, there is a way. Remember that dependencies do not fall from heaven. People include them in code they write, or in 3rd party object libs they link with.
-- pa
Thursday, March 24, 2016 9:48 PM -
Thanks for posting here.
You can set MSBuild BuildProjectReferences property to false. Refer to this link for more information.
Friday, March 25, 2016 6:31 AM -
Did you tried static linkage with /MT option. In that way you don't have to do anything else.
Thanks
Rupesh Shukla
- Edited by Pintu Shukla Friday, March 25, 2016 7:44 PM
Friday, March 25, 2016 2:31 PM -
Thanks for the help i solved the problem.
It requires little macro managing.
main pragram <- My DLL(.h, .lib, .dll) <- 3rd party (.h, .lib)
Since main program include .h from My DLL and .h from My DLL includes .h from 3rd party lib i
added conditional macro inclusion in .h file from My DLL. Something like this#ifndef USE_MY_DLL
#include <ThirdPartyLibHeader.h>
#endifIn this case main program has to define the USE_MY_DLL in order to use the DLL.
If main program does not define the macro linker will complain about missing header file.Saturday, March 26, 2016 12:36 PM