Additional Information
If the functions you are trying to use are already bundled into a DLL with an import library, you can skip steps 1 through 6.
If you still has a link error, it is most probably due to
name mangling issue. The C++ language allows you to overide some functions (such as methods in Object Oriented Programming). To resolve some names conflits, the C++ compiler add name mangling in order to have a unique name indentifier.
So when you call a C library in C++ programm, the C++ compiler needs to know that it do not need to modify the name. If it is the case, the name created by the C++ compiler is different from what is in your C code, and explain the linkage error.
In order to solve it, you need to add the following code in the header file (.h) related to you .c file.
#ifdef __cplusplus extern "C" { #endif /* The functions you want to keep the same in C and C++ */ #ifdef __cplusplus } #endif |