C语言 Visual Studio 2010 中的“错误 LNK2019:无法解析的外部符号”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23276399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 11:02:32  来源:igfitidea点击:

"error LNK2019: unresolved external symbol" error in Visual Studio 2010

cvisual-studio-2010lnk2019libsndfile

提问by user3127389

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

我正在尝试编译和运行使用libsndfile库进行声音文件处理的 C 代码。

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

我已经使用这个路径添加了头文件: 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.

我还使用此路径链接了库: 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

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!

有人可以在这里确定问题吗?我是使用 Visual Studio 的新手,我真的需要帮助!

回答by VinayLondhe

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.

1) 确保您下载的是 32 位的 libsndfile(libsndfile-1.0.25-w32-setup.exe) 包,因为 Visual Studio 编译器是 32 位的。

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

2)点击libsndfile的setup.exe(libsndfile-1.0.25-w32-setup.exe)文件安装库。

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

3) 创建项目后,请执行以下 2 个步骤:

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.

i)转到调试>>项目属性>>配置属性>>C/C++>>常规>>附加包含目录>>点击右侧的箭头,然后点击编辑>>在这里,添加路径libsndfile 目录中的 include 文件夹。

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.

ii) 步骤 (i) 完成后,单击 Configuration Properties >> General >> Additional Library Directories 中的 Linker >> 单击右侧的箭头,然后单击 Edit >> Here,添加 . .lib 文件。您可能必须输入整个路径,因为浏览选项不显示 .lib 文件。所以,在我的例子中,我输入了 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.

最后,你完成了!您的代码现在应该可以编译并运行而不会抛出任何错误。

回答by Mehdi Benkirane

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.

缺少指定库的文件夹目录(.lib 添加到附加依赖项) VC++ 目录视图
单击库目录,单击右侧的下拉按钮并选择
并指定它应该工作的目录。

回答by Payman

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

我有一个类似的问题,问题是混合了一个 x64 库和一个 win32 项目。