Question

Forgive the convoluted title.

The setup for this problem is as follows:

I have an open source lib I have built into a bunch of .libs (VTK if you were curious)

I have a library that uses the aforementioned static lib. Lets call it Lib A.

I also have an application that uses the aforementioned library (i.e. VTK) AND also uses Lib A.

During build time, I get a linker error telling me that a function called from Lib A has already been defined in a library that is linked to the application (error: LNK2005)

Any ideas on how to fix this short of switching everything to be dynamically linked?

Was it helpful?

Solution

Alright. I figured out what I was doing wrong.

Lib A was using the statically built version of VTK while the main app was linking against a dynamic-linked version of VTK.

So the problem really was that I had the same functions defined in a .lib and a .dll which caused the linker to fail.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top