Click here to Skip to main content
15,117,719 members
Articles / Programming Languages / C++
Tip/Trick
Posted 18 Jan 2012

Tagged as

Stats

40.1K views
5 bookmarked

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

Rate me:
Please Sign up or sign in to vote.
3.38/5 (8 votes)
24 Jan 2012CPOL
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)

Share

About the Author

Lakamraju Raghuram
Technical Lead
India India
_____________________________________________________________

Did my masters from IIT-M in Advanced Manufacturing Technology and working mainly on C++ in CAD domain from 2004 onwards.
Working on web technologies using Angular 7.0 and above, HTML5, CSS3 from 2015.

Comments and Discussions

 
General[My vote of 1] Shutting up the linker does not solve your problem Pin
.:floyd:.21-Mar-14 6:19
Member.:floyd:.21-Mar-14 6:19 
GeneralRe: [My vote of 1] Shutting up the linker does not solve your problem Pin
Lakamraju Raghuram28-Mar-14 2:44
MemberLakamraju Raghuram28-Mar-14 2:44 
GeneralRe: [My vote of 1] Shutting up the linker does not solve your problem Pin
.:floyd:.30-Mar-14 11:22
Member.:floyd:.30-Mar-14 11:22 
GeneralRe: [My vote of 1] Shutting up the linker does not solve your problem Pin
Lakamraju Raghuram31-Mar-14 23:05
MemberLakamraju Raghuram31-Mar-14 23:05 
GeneralRe: [My vote of 1] Shutting up the linker does not solve your problem Pin
.:floyd:.3-Apr-14 11:23
Member.:floyd:.3-Apr-14 11:23 
GeneralReason for my vote of 3 Now i know! Pin
Sampson Wei29-Jan-12 0:15
MemberSampson Wei29-Jan-12 0:15 
GeneralReason for my vote of 5 Good to know, I would never have ima... Pin
YvesDaoust23-Jan-12 21:39
MemberYvesDaoust23-Jan-12 21:39 
GeneralHmmm...correct but an addition: We should not again use this... Pin
Lakamraju Raghuram23-Jan-12 18:42
MemberLakamraju Raghuram23-Jan-12 18:42 
GeneralReason for my vote of 1 You can write your own wrapper for o... Pin
dvpsun23-Jan-12 18:13
Memberdvpsun23-Jan-12 18:13 
GeneralJon, I am speaking about the hopeless case, where we don't ... Pin
Lakamraju Raghuram23-Jan-12 16:00
MemberLakamraju Raghuram23-Jan-12 16:00 
GeneralReason for my vote of 2 Not a resolution. May cause chaos. Pin
Jon Summers23-Jan-12 8:33
MemberJon Summers23-Jan-12 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.