How to build an image (DLL/EXE) when two of its included libraries have the same symbol (say function/variable) using VC++






3.38/5 (8 votes)
How to build an image (DLL/EXE) when two of its included libraries have the same symbol (say function/variable) using VC++
Say we are building an EXE which utilizes two
static
libraries, external_1.lib and external_2.lib.
external_1.lib has two functions FunA()
and FunB()
,
while external_2.lib has FunA()
and FunC()
.
Note: FunA() is there in both the libs !!!, which is practical in the real world.
Now in our EXE's main()
, we have code like shown below:
void main()
{
FunB(); // from external_1.lib
FunC(); // from external_2.lib
FunA(); // from external_1.lib / external_2.lib ????
}
The compiler will obviously throw a linker error saying that FunA
is there in multiple objs.
If both these libs are of 3rd party, then we cannot compile them. How to resolve this ??
Simple. Use the linker option /FORCE:MULTIPLECheck this link: http://msdn.microsoft.com/en-us/library/70abkas3.aspx[^]