0

I'm calling a C static-link library in VS2010 by wrapping the header file with extern "C", but I'm still getting a LNK2001: unresolved external symbol. I'm calling the same .lib file somewhere else with no problems and I'm reusing old code from somewhere else that definitely works. The code I'm using can be found at github.com/toots/microsoft-audio-watermarking. I'm trying to use the "thrabs" function found in hthres.h. I can't think of any obvious reasons it's not working. Here's the example code. thrabs is the c external. Is it possible my variable _fm_lookup which is normally defined in C++ is the problem?

int i;
for(i = 0; i < NFREQ; i++) 
    _fm_lookup[i] = thrabs((0.5 + i) * (float) fs * 0.5 / (float) NFREQ);

the C static lib is being included by using

extern "C" { #include "htres.h" }

the error is

Error   37  error LNK2001: unresolved external symbol _fm_lookup    C:\Users\David\Documents\Projects\watermarking\Builds\VisualStudio2010\internal2003.lib(hthres.obj)
Alan Stokes
  • 18,815
  • 3
  • 45
  • 64
daithioronain
  • 99
  • 1
  • 6

1 Answers1

2

Needed to move the offending code into its own c file and call it from there while using extern "C". Painful lesson learned.

daithioronain
  • 99
  • 1
  • 6