Search code examples
libsndfile

libsndfile library build error in VS 2012 Vc++ app project


I am creating Visual Studio VC++ app project on Win 7, that utilizes the libsndfile library.

The library( libsndfile-1.dll,libsndfile-1.dll) is at :

C:\SVN\US\AdditionalIncludeDir\libsndfile

and its headers(sndfile.hh,sndfile.h) at

C:\SVN\US\AdditionalIncludeDir\Include

the Visual Studio Project is at :

C:\SVN\US\Simulation\audioSim.vcxproj

I have added the library header reference as:

Project properties->C/C++->General->Additional Include Directories-> ..\AdditionalIncludeDir\Include
and static lib reference as

Project properties->Linker>Additional dependencies: libsndfile-1.lib Project properties->Linker>Additional Library Dir:..\AdditionalIncludeDir\libsndfile

I also have added

..\AdditionalIncludeDir\libsndfile

to path in user environment variable in Win 7.

The toplevel C++ file uses the library as:

SndfileHandle mic1(".\\filedata\\mic1.wav");

where mic1.wav is at

C:\SVN\US\Simulation\filedata

Building the project still gives me error:

error LNK2019: unresolved external symbol _sf_open referenced in
 function "public: __thiscall SndfileHandle::SndfileHandle(char const
 *,int,int,int,int)" (??0SndfileHandle@@QAE@PBDHHHH@Z)

Why would this happen?

Thanks
sedy


Solution

  • I also had this problem. I had set "Additional Include Directories" (C:\Program Files (x86)\Mega-Nerd\libsndfile\include) and "Additional Library Directories" (C:\Program Files %28x86%29\Mega-Nerd\libsndfile\lib) in the project settings.

    This fixed the problem: Go to project properties -> Configuration properties -> Linker -> Input and type in the lib file name libsndfile-1.lib in the "Additional Dependencies" field.