3

I'm trying to compile and run a C code that is using libsndfile library for sound files processing.

I have added the header file using this path: project's Properties (in C/C++ -> General -> Additional Include Directories)

Also i have linked the library using this path: Project Properties -> Linker -> Input -> Additional Dependencies.

But while debugging, i get the following errors:

1>sil.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification 1>sil.obj : error LNK2019: unresolved external symbol _sf_write_sync referenced in function _main 1>sil.obj : error LNK2019: unresolved external symbol _sf_write_double referenced in function _main 1>sil.obj : error LNK2019: unresolved external symbol _sf_close referenced in function _main 1>sil.obj : error LNK2019: unresolved external symbol _sf_read_double referenced in function _main 1>sil.obj : error LNK2019: unresolved external symbol _sf_open referenced in function _main 1>c:\users\anam\documents\visual studio 2010\Projects\silence\Debug\silence.exe : fatal error LNK1120: 5 unresolved externals

Can someone please identify the problem here? I'm new at using Visual Studio and I really need help!

user3127389
  • 87
  • 1
  • 1
  • 6
  • 1
    Your linking is not working correctly, for some reason. I would recommend you check the symbols contained in the .lib file you're trying to link to with the following command: `dumpbin.exe -headers libsndfile.lib`. Issue that command in the "Visual Studio Command Prompt" and take a look at the resulting output. Check to make sure the exact symbols you're trying to link to are contained there (including the leading underscore). – aardvarkk Apr 24 '14 at 18:46
  • Have you gone through [this](https://msdn.microsoft.com/en-us/library/799kze2z%28v=vs.100%29.aspx)? – Pranav Aug 11 '15 at 10:17

3 Answers3

4

I faced the same problem. I solved it as follows.

1)Make sure that you are downloading the 32 bit libsndfile(libsndfile-1.0.25-w32-setup.exe) package because the Visual studio compiler is 32 bit.

2)Install the library by clicking on the setup.exe(libsndfile-1.0.25-w32-setup.exe) file of libsndfile.

3)After creating your project, do the following 2 steps:

i)Go to Debug >> Project Properties >> Configuration Properties >> C/C++ >> General >> Additional Include Directories >> Click on the arrow on the right hand side and then click on edit >> Here, add the path of the include folder in your libsndfile directory.

ii)After step (i) is complete, click on Linker in Configuration Properties >> General >> Additional Library Directories >> Click on the arrow on the right hand side and then click on edit >> Here, add the path of the .lib file. You may have to type in the entire path since the browse option does not show the .lib file. So, in my case I typed C:\Program Files (x86)\Mega-Nerd\libsndfile\lib\libsndfile-1.lib.

Finally, you are done! Your code should compile and work now without throwing any errors.

  • "Visual studio compiler is 32 bit". That's actually incorrect. Visual Studio compiler generates 32 or 64 bit code depending on the settings you supply to it. Whether the compiler executable itself (cl.exe) is 32 bit or 64 bit is completely irrelevant. – AnT stands with Russia Mar 19 '16 at 01:46
0

Missing to specify the folder directory of the library (.lib added to Additional Dependencies) VC++ Directories view
Click on Library Directories, click the drop-down button on the right and choose
and specify the directory it should work.

Mehdi Benkirane
  • 437
  • 4
  • 7
0

I had a similar issue and the problem was mixing a x64 lib and a win32 project.

Payman
  • 2,630
  • 1
  • 12
  • 18