我确信之前已经提出过这个问题,但我已经尽可能多地搜索了SO,但仍然无法找到错误的确切原因。因此发布一个新的。
我在项目中使用C ++库(txmpp)。该库已正确添加,但我得到了许多未解决的外部符号问题,主要是在我尝试使用的类的构造函数中。例如,在以下类中 -
xmppthread.h
#ifndef _HELLO_XMPPTHREAD_H_
#define _HELLO_XMPPTHREAD_H_
#include "../../thread.h"
#include "../../xmppclientsettings.h"
#include "xmpppump.h"
namespace txmpp {
class XmppThread: public txmpp::Thread, XmppPumpNotify, txmpp::MessageHandler {
public:
XmppThread();
~XmppThread();
XmppClient* client() { return pump_->client(); }
void ProcessMessages(int cms);
void Login(const txmpp::XmppClientSettings & xcs);
void Disconnect();
private:
XmppPump* pump_;
void OnStateChange(txmpp::XmppEngine::State state);
void OnMessage(txmpp::Message* pmsg);
};
} // namespace txmpp
#endif // _HELLO_XMPPTHREAD_H_
xmppthread.cc
#include "xmppthread.h"
#include <assert.h>
#include "../../prexmppauthimpl.h"
#include "../../xmppasyncsocketimpl.h"
#include "../../xmppclientsettings.h"
namespace txmpp {
namespace {
const uint32 MSG_LOGIN = 1;
const uint32 MSG_DISCONNECT = 2;
struct LoginData : public MessageData {
LoginData(const XmppClientSettings& s) : xcs(s) {}
virtual ~LoginData() {}
XmppClientSettings xcs;
};
} // namespace
XmppThread::XmppThread() {
pump_ = new XmppPump(this);
}
XmppThread::~XmppThread() {
delete pump_;
}
void XmppThread::ProcessMessages(int cms) {
Thread::ProcessMessages(cms);
}
void XmppThread::Login(const XmppClientSettings& xcs) {
Post(this, MSG_LOGIN, new LoginData(xcs));
}
void XmppThread::Disconnect() {
Post(this, MSG_DISCONNECT);
}
void XmppThread::OnStateChange(XmppEngine::State state) {
}
void XmppThread::OnMessage(Message* pmsg) {
switch (pmsg->message_id) {
case MSG_LOGIN: {
assert(pmsg->pdata);
LoginData* data = reinterpret_cast<LoginData*>(pmsg->pdata);
pump_->DoLogin(data->xcs, new XmppAsyncSocketImpl(true),
new PreXmppAuthImpl());
delete data;
}
break;
case MSG_DISCONNECT:
pump_->DoDisconnect();
break;
default:
assert(false);
}
}
} // namespace hello
我收到以下错误 -
1>XMPPController.obj : error LNK2019: unresolved external symbol "public: __thiscall txmpp::XmppThread::XmppThread(void)" (??0XmppThread@txmpp@@QAE@XZ) referenced in function "public: void __thiscall XMPPController::Init(void)" (?Init@XMPPController@@QAEXXZ)
1>XMPPController.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall txmpp::XmppThread::~XmppThread(void)" (??1XmppThread@txmpp@@UAE@XZ) referenced in function "public: void __thiscall XMPPController::Init(void)" (?Init@XMPPController@@QAEXXZ)
我通常只在未提供函数定义(本例中为构造函数/析构函数)时才会看到此类链接器错误。但是,您可以看到包含的定义。只有在我的项目中执行此操作时才会生成此错误 -
xmpp::XmppThread thread;
一旦删除声明语句,就会出现链接错误。问题是这些代码都不是由我编写的,而是从txmpp库中获取的。这个特殊的课程来自Google的libjingle图书馆,所以我相信我在这里犯了一些非常愚蠢的错误。
我不希望这个问题成为&#34;这是我的代码,解决问题&#34;一。相反,我想知道尽管有声明,可能出现未解决的外部符号错误的情况是什么?(代码是为了提供实现的证据)
有什么建议吗?
更新
这是关闭supress启动横幅选项后我得到的确切输出 -
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification
1>AirPlaySystem.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
1>LIBCMTD.lib(sscanf.obj) : warning LNK4006: _vsscanf already defined in s3e_d.lib(iwcrt_win32.obj); second definition ignored
1>LIBCMTD.lib(strtoq.obj) : warning LNK4006: _strtof already defined in s3e_d.lib(iwcrt_common.obj); second definition ignored
1> Creating library Debug_BarnC_vc12_x86\BarnC.lib and object Debug_BarnC_vc12_x86\BarnC.exp
1>XMPPController.obj : error LNK2019: unresolved external symbol "public: __thiscall txmpp::XmppThread::XmppThread(void)" (??0XmppThread@txmpp@@QAE@XZ) referenced in function "public: void __thiscall XMPPController::Init(void)" (?Init@XMPPController@@QAEXXZ)
1>XMPPController.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall txmpp::XmppThread::~XmppThread(void)" (??1XmppThread@txmpp@@UAE@XZ) referenced in function "public: void __thiscall XMPPController::Init(void)" (?Init@XMPPController@@QAEXXZ)
1>Debug_BarnC_vc12_x86\BarnC.s86 : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
更新2: 这是添加详细链接器命令行选项 -
后的详细链接器输出1> Microsoft (R) Incremental Linker Version 12.00.31101.0
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> "/OUT:Debug_BarnC_vc12_x86\BarnC.s86" /INCREMENTAL /LIBPATH:d:/marmalade/7.4/modules/third_party/sqlite/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/iwutil/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/third_party/libjpeg/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/third_party/zlib/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/third_party/libpng/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/iw2d/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/iwgx/atitools /LIBPATH:d:/marmalade/7.4/modules/iwgx/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/iwgl/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/iwgeom/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/iwresmanager/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/iwgxfont/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/third_party/tiniconv/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/iwui/lib/x86 /LIBPATH:d:/marmalade/7.4/modules/iwhttp/lib/x86 /LIBPATH:d:/marmalade/7.4/extensions/s3etxmpp/lib/x86 /LIBPATH:d:/marmalade/7.4/s3e/lib/x86 vc6_compat.lib sqlite_d.lib iwutil_d.lib jpeg_d.lib z_d.lib png_d.lib iw2d_d.lib ATI_Compress_MT_VC7.lib iwgx_d.lib iwgl_d.lib iwgeom_d.lib iwresmanager_d.lib iwgxfont_ttf_d.lib tiniconv_d.lib iwui_d.lib iwhttp_d.lib s3eTxmpp_d.lib s3e_cpp_d.lib s3e_d.lib s3e_api_iwgl.lib /NODEFAULTLIB:libcmt /MANIFEST:NO /DEBUG "/PDB:Debug_BarnC_vc12_x86\BarnC.pdb" /SUBSYSTEM:WINDOWS /OPT:NOREF /OPT:NOICF /TLBID:1 "/ENTRY:DllEntryPoint" /DYNAMICBASE /NXCOMPAT "/IMPLIB:Debug_BarnC_vc12_x86\BarnC.lib" /MACHINE:X86 /include:_IwMain /include:_raise /include:_DllEntryPoint@12 /force:multiple /VERBOSE:LIB /DLL Debug_BarnC_vc12_x86\AirPlaySystem.obj
1> Debug_BarnC_vc12_x86\CTextField.obj
1> Debug_BarnC_vc12_x86\Chat.obj
1> Debug_BarnC_vc12_x86\ChatController.obj
1> Debug_BarnC_vc12_x86\ChatGroup.obj
1> Debug_BarnC_vc12_x86\ChatMenu.obj
1> Debug_BarnC_vc12_x86\Contact.obj
1> Debug_BarnC_vc12_x86\ContactController.obj
1> Debug_BarnC_vc12_x86\HttpManager.obj
1> Debug_BarnC_vc12_x86\LoginMenu.obj
1> Debug_BarnC_vc12_x86\Main.obj
1> Debug_BarnC_vc12_x86\MainMenu.obj
1> Debug_BarnC_vc12_x86\MenuBase.obj
1> Debug_BarnC_vc12_x86\MenuController.obj
1> Debug_BarnC_vc12_x86\PVRTexTool_interface.obj
1> Debug_BarnC_vc12_x86\SimpleTouch.obj
1> Debug_BarnC_vc12_x86\UnivApp.obj
1> Debug_BarnC_vc12_x86\XMPPController.obj
1> Debug_BarnC_vc12_x86\md5c.obj
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification
1>AirPlaySystem.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
1>
1> Searching libraries
1> Searching d:/marmalade/7.4/modules/third_party/sqlite/lib/x86\sqlite_d.lib:
1> Searching d:/marmalade/7.4/modules/iwutil/lib/x86\iwutil_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libjpeg/lib/x86\jpeg_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/zlib/lib/x86\z_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libpng/lib/x86\png_d.lib:
1> Searching d:/marmalade/7.4/modules/iw2d/lib/x86\iw2d_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/atitools\ATI_Compress_MT_VC7.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/lib/x86\iwgx_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgl/lib/x86\iwgl_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgeom/lib/x86\iwgeom_d.lib:
1> Searching d:/marmalade/7.4/modules/iwresmanager/lib/x86\iwresmanager_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgxfont/lib/x86\iwgxfont_ttf_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/tiniconv/lib/x86\tiniconv_d.lib:
1> Searching d:/marmalade/7.4/modules/iwui/lib/x86\iwui_d.lib:
1> Searching d:/marmalade/7.4/modules/iwhttp/lib/x86\iwhttp_d.lib:
1> Searching d:/marmalade/7.4/extensions/s3etxmpp/lib/x86\s3eTxmpp_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_cpp_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_api_iwgl.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\LIBCMTD.lib:
1>LIBCMTD.lib(sscanf.obj) : warning LNK4006: _vsscanf already defined in s3e_d.lib(iwcrt_win32.obj); second definition ignored
1>LIBCMTD.lib(strtoq.obj) : warning LNK4006: _strtof already defined in s3e_d.lib(iwcrt_common.obj); second definition ignored
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1> Searching d:/marmalade/7.4/modules/third_party/sqlite/lib/x86\sqlite_d.lib:
1> Searching d:/marmalade/7.4/modules/iwutil/lib/x86\iwutil_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libjpeg/lib/x86\jpeg_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/zlib/lib/x86\z_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libpng/lib/x86\png_d.lib:
1> Searching d:/marmalade/7.4/modules/iw2d/lib/x86\iw2d_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/atitools\ATI_Compress_MT_VC7.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/lib/x86\iwgx_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgl/lib/x86\iwgl_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgeom/lib/x86\iwgeom_d.lib:
1> Searching d:/marmalade/7.4/modules/iwresmanager/lib/x86\iwresmanager_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgxfont/lib/x86\iwgxfont_ttf_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/tiniconv/lib/x86\tiniconv_d.lib:
1> Searching d:/marmalade/7.4/modules/iwui/lib/x86\iwui_d.lib:
1> Searching d:/marmalade/7.4/modules/iwhttp/lib/x86\iwhttp_d.lib:
1> Searching d:/marmalade/7.4/extensions/s3etxmpp/lib/x86\s3eTxmpp_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_cpp_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_api_iwgl.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\LIBCMTD.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1> Searching d:/marmalade/7.4/modules/third_party/sqlite/lib/x86\sqlite_d.lib:
1> Searching d:/marmalade/7.4/modules/iwutil/lib/x86\iwutil_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libjpeg/lib/x86\jpeg_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/zlib/lib/x86\z_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libpng/lib/x86\png_d.lib:
1> Searching d:/marmalade/7.4/modules/iw2d/lib/x86\iw2d_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/atitools\ATI_Compress_MT_VC7.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/lib/x86\iwgx_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgl/lib/x86\iwgl_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgeom/lib/x86\iwgeom_d.lib:
1> Searching d:/marmalade/7.4/modules/iwresmanager/lib/x86\iwresmanager_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgxfont/lib/x86\iwgxfont_ttf_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/tiniconv/lib/x86\tiniconv_d.lib:
1> Searching d:/marmalade/7.4/modules/iwui/lib/x86\iwui_d.lib:
1> Searching d:/marmalade/7.4/modules/iwhttp/lib/x86\iwhttp_d.lib:
1> Searching d:/marmalade/7.4/extensions/s3etxmpp/lib/x86\s3eTxmpp_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_cpp_d.lib:
1>
1> Finished searching libraries
1> Creating library Debug_BarnC_vc12_x86\BarnC.lib and object Debug_BarnC_vc12_x86\BarnC.exp
1>
1> Searching libraries
1> Searching d:/marmalade/7.4/modules/third_party/sqlite/lib/x86\sqlite_d.lib:
1> Searching d:/marmalade/7.4/modules/iwutil/lib/x86\iwutil_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libjpeg/lib/x86\jpeg_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/zlib/lib/x86\z_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libpng/lib/x86\png_d.lib:
1> Searching d:/marmalade/7.4/modules/iw2d/lib/x86\iw2d_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/atitools\ATI_Compress_MT_VC7.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/lib/x86\iwgx_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgl/lib/x86\iwgl_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgeom/lib/x86\iwgeom_d.lib:
1> Searching d:/marmalade/7.4/modules/iwresmanager/lib/x86\iwresmanager_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgxfont/lib/x86\iwgxfont_ttf_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/tiniconv/lib/x86\tiniconv_d.lib:
1> Searching d:/marmalade/7.4/modules/iwui/lib/x86\iwui_d.lib:
1> Searching d:/marmalade/7.4/modules/iwhttp/lib/x86\iwhttp_d.lib:
1> Searching d:/marmalade/7.4/extensions/s3etxmpp/lib/x86\s3eTxmpp_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_cpp_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_api_iwgl.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\LIBCMTD.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1>
1> Finished searching libraries
1>
1> Searching libraries
1> Searching d:/marmalade/7.4/modules/third_party/sqlite/lib/x86\sqlite_d.lib:
1> Searching d:/marmalade/7.4/modules/iwutil/lib/x86\iwutil_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libjpeg/lib/x86\jpeg_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/zlib/lib/x86\z_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/libpng/lib/x86\png_d.lib:
1> Searching d:/marmalade/7.4/modules/iw2d/lib/x86\iw2d_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/atitools\ATI_Compress_MT_VC7.lib:
1> Searching d:/marmalade/7.4/modules/iwgx/lib/x86\iwgx_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgl/lib/x86\iwgl_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgeom/lib/x86\iwgeom_d.lib:
1> Searching d:/marmalade/7.4/modules/iwresmanager/lib/x86\iwresmanager_d.lib:
1> Searching d:/marmalade/7.4/modules/iwgxfont/lib/x86\iwgxfont_ttf_d.lib:
1> Searching d:/marmalade/7.4/modules/third_party/tiniconv/lib/x86\tiniconv_d.lib:
1> Searching d:/marmalade/7.4/modules/iwui/lib/x86\iwui_d.lib:
1> Searching d:/marmalade/7.4/modules/iwhttp/lib/x86\iwhttp_d.lib:
1> Searching d:/marmalade/7.4/extensions/s3etxmpp/lib/x86\s3eTxmpp_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_cpp_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_d.lib:
1> Searching d:/marmalade/7.4/s3e/lib/x86\s3e_api_iwgl.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\LIBCMTD.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1>
1> Finished searching libraries
1>XMPPController.obj : error LNK2019: unresolved external symbol "public: __thiscall txmpp::XmppThread::XmppThread(void)" (??0XmppThread@txmpp@@QAE@XZ) referenced in function "public: void __thiscall XMPPController::Init(void)" (?Init@XMPPController@@QAEXXZ)
1>XMPPController.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall txmpp::XmppThread::~XmppThread(void)" (??1XmppThread@txmpp@@UAE@XZ) referenced in function "public: void __thiscall XMPPController::Init(void)" (?Init@XMPPController@@QAEXXZ)
1>Debug_BarnC_vc12_x86\BarnC.s86 : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
答案 0 :(得分:0)
Marmalade(我用来构建此项目的SDK工具链)无法将.cc文件识别为源文件。我将它们改为.cpp,然后他们就被识别出来了。但是,库中仍然存在很多错误,但至少我知道如何解决它们。 谢谢你的帮助。