Search code examples
c++visual-c++linkerunresolved-external

fatal error LNK1127: library is corrupt --> after adding extern "C" to function prototype


I have an external library made using C code. I wish to call a function from the library in my c++ project. The original format of the function prototype was.

extern void butterThreeBp(real_T eml_dt, real_T eml_fl, real_T eml_fu, real_T eml_b3[7], real_T eml_a3[7]);

And this caused the following linker error in MSVC2008

error LNK2019: unresolved external symbol "void __cdecl butterThreeBp(double,double,double,double * const,double * const)" (?butterThreeBp@@YAXNNNQAN0@Z) referenced in function "public: void __thiscall myThread::setDRNLc(double)" (?setDRNLc@myThread@@QAEXN@Z)

I then changed this prototype to

extern "C" void ...

and then get the following error:

\butterThreeBp.lib : fatal error LNK1127: library is corrupt

I have rebuilt the library numerous times and am pretty certain that it is not corrupt. Any help would be great. Thanks!!


Solution

  • You do not have to use the included LCC compiler with MATLAB. The simplest solution is to get MATLAB to use VC++. http://www.mathworks.com/support/compilers/R2010b/index.html