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.

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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.
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
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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.