C++ 错误 LNK2019 未解析的外部符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12297952/
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-08-27 16:08:11  来源:igfitidea点击:

error LNK2019 unresolved external symbol

c++symbolsunresolved-externallnk2019

提问by Steven Tang Ti Khoon

I am quite new to C++ so I downloaded a sample C++ program. The sample program seems to hit the following error when it is compiling :-

我对 C++ 很陌生,所以我下载了一个示例 C++ 程序。示例程序在编译时似乎遇到以下错误:-

Error   22  error LNK2019: unresolved external symbol _acsEnumServerNames@12    referenced in function "protected: virtual int __thiscall COpenTsrv::OnInitDialog(void)" (?OnInitDialog@COpenTsrv@@MAEHXZ)  Opentsrv.obj    

I traced it to the referred function but I do not know anything wrong with it ?

我将其追踪到引用的函数,但我不知道它有什么问题?

BOOL COpenTsrv::OnInitDialog() 
{
CDialog::OnInitDialog();

CenterWindow();


acsEnumServerNames(ST_CSTA, AddToList, (unsigned long) (CComboBox*)&m_TserverListControl);

UpdateData(FALSE);

The following is the build log. Apparently there are still other errors but would like to start with the first one.

以下是构建日志。显然还有其他错误,但想从第一个开始。

1>Generating Code...
1>Compiling resources...
1>Compiling manifest to resources...
1>Linking...
1>Opentsrv.obj : error LNK2019: unresolved external symbol _acsEnumServerNames@12  referenced in function "protected: virtual int __thiscall COpenTsrv::OnInitDialog(void)" (? OnInitDialog@COpenTsrv@@MAEHXZ)
1>Opentsrv.obj : error LNK2019: unresolved external symbol _acsQueryAuthInfo@8 referenced in function "protected: void __thiscall COpenTsrv::OnSelchangeTserverlist(void)" (?OnSelchangeTserverlist@COpenTsrv@@IAEXXZ)
1>Opentsrv.obj : error LNK2019: unresolved external symbol _acsAbortStream@8 referenced in function "protected: virtual void __thiscall COpenTsrv::OnOK(void)" (?OnOK@COpenTsrv@@MAEXXZ)
1>Tsapi.obj : error LNK2001: unresolved external symbol _acsAbortStream@8
1>Opentsrv.obj : error LNK2019: unresolved external symbol _acsEventNotify@16 referenced in function "protected: virtual void __thiscall COpenTsrv::OnOK(void)" (?OnOK@COpenTsrv@@MAEXXZ)
1>Opentsrv.obj : error LNK2019: unresolved external symbol _acsOpenStream@60 referenced in function "protected: virtual void __thiscall COpenTsrv::OnOK(void)" (?OnOK@COpenTsrv@@MAEXXZ)
1>Opentsrv.obj : error LNK2019: unresolved external symbol _cstaMonitorDevice@20 referenced in function "protected: long __thiscall COpenTsrv::OnTsapiAcsConfirmation(unsigned int,long)" (?OnTsapiAcsConfirmation@COpenTsrv@@IAEJIJ@Z)
1>Sampldlg.obj : error LNK2019: unresolved external symbol _cstaMakeCall@20 referenced in function "protected: void __thiscall CSampleDlg::OnCall(void)" (?OnCall@CSampleDlg@@IAEXXZ)
1>Sampldlg.obj : error LNK2019: unresolved external symbol _cstaClearConnection@16 referenced in function "protected: void __thiscall CSampleDlg::OnHangup(void)" (?OnHangup@CSampleDlg@@IAEXXZ)
1>Sampldlg.obj : error LNK2019: unresolved external symbol _cstaAnswerCall@16 referenced in function "protected: void __thiscall CSampleDlg::OnAnswer(void)" (?OnAnswer@CSampleDlg@@IAEXXZ)
1>Tsapi.obj : error LNK2019: unresolved external symbol _acsGetEventPoll@20 referenced in function "protected: long __thiscall CTsapiWnd::OnTsapiMsg(unsigned int,long)" (?OnTsapiMsg@CTsapiWnd@@IAEJIJ@Z)
1>C:\Users\steventang\Documents\Visual Studio 2005\Projects\TSAPINEW\Debug\TSAPINEW.exe    : fatal error LNK1120: 10 unresolved externals
1>Build log was saved at "file://c:\Users\steventang\Documents\Visual Studio 2005\Projects\TSAPINEW\TSAPINEW\Debug\BuildLog.htm"
1>TSAPINEW - 12 error(s), 21 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Any help to point me to the right direction would very much be appreciated.

任何帮助我指向正确方向的帮助将不胜感激。

Thanks

谢谢

回答by Alex

Seems like your compilation was sucessfull. Only the linking did not work.

看来你的编译成功了。只有链接不起作用。

Probably the linker is complaining because you defined the header of the method "acsEnumServerNames" but you did not provide an implementation of the method.

链接器可能会抱怨,因为您定义了方法“acsEnumServerNames”的标头,但您没有提供该方法的实现。

Maybe you used a header-file but you did not provide the library to which the header belongs ?

也许您使用了头文件,但没有提供头文件所属的库?

Find out to which pakage "acsEnumServerNames" belongs and check if you have the implementation of the method in some .c/.cpp file, or if the implementation should be provided by some library on which you do rely.

找出“acsEnumServerNames”属于哪个包,并检查您是否在某些 .c/.cpp 文件中实现了该方法,或者该实现是否应该由您依赖的某个库提供。