Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ static library using functions defined in another cpp project

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.

like image 597
yassine Avatar asked Sep 08 '26 04:09

yassine


1 Answers

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.

like image 67
Elemental Avatar answered Sep 09 '26 18:09

Elemental



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!