3

I am working on a VS 2012 project and i am using an already compiled static library (that was compiled in VS 2013). The library references the "vacopy" method that is VS 2013 compatible but not found in VS 2012.

When I compile my cpp project, I get the linking error : error LNK2019: unresolved symbol __imp___vacopy

My first reflex was to add the declaration and definition of va_copy in my project, so I included the following:

in a header file :

void va_copy(va_list dest, va_list src);

in a cpp file :

void va_copy(va_list dest,va_list src)
{
   dest = src;
}

But this didn't resolve the problem, I still get the same linking error.

Thanks in advance for your answers.

yassine
  • 31
  • 3
  • See: http://stackoverflow.com/questions/5159353/how-can-i-get-rid-of-the-imp-prefix-in-the-linker-in-vc – Photon Aug 25 '15 at 08:11

1 Answers1

1

You basic problem is that the library was compiled to link with standard libraries in a DLL (thus the __imp__); you application is probably set differently (to grab standard calls from a statically linked in library).

You either have to match your compiler settings (in this case project properties -> C/C++ -> Code Generation section) where you can specify to use DLL or static options.

It's often worth checking if there is a way to specify to the include files which version of the link you need - some libraries (CURL for example) allow you to define compiler predefines to control exactly which functions are linked to.

Elemental
  • 7,365
  • 2
  • 28
  • 33
  • Thank you for your answer. I checked the compilation settings for the library and you are right : the library was compiled to link with standard libraries in a DLL. I also checked my application's settings and they are the same as the library: they both use DLL options. – yassine Aug 25 '15 at 08:49
  • The other thing you can mess with is the 'platform toolset' setting but I assume that 2012 doesn't have installed tools for 2013 and although these can be installed I believe this gets quite tricky. A mismatch in debug/release versions can also be an issue I think – Elemental Aug 25 '15 at 10:31
  • Also in my experience you need to do a full clean+rebuild because VS is not so good with dependancies when you change the config settings – Elemental Aug 25 '15 at 10:32
  • I cleaned then rebuilt the project but the problem is still there. I guess it is (and correct me if i'am wrong) because the library expects the function "va_copy" to be dll exported (since it has been compiled in windows). Which is not the case in my definition above, not sure about that though. – yassine Aug 25 '15 at 12:23