65.9K
CodeProject is changing. Read more.
Home

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

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.38/5 (8 votes)

Jan 18, 2012

CPOL
viewsIcon

44960

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:MULTIPLE
Check this link: http://msdn.microsoft.com/en-us/library/70abkas3.aspx[^]