Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++

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)
24 Jan 2012CPOL 45K  
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:

C++
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[^]

License

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