Code::Blocks 中 wxWidgets 的未定义引用

Undefined refrence with wxWidgets in Code::Blocks

我已经下载了 wxWidgets 3.1.2 的预构建二进制文件并将其放在我的 minGW 文件夹中。在 Code::Blocks 我 运行 创建 wxWidgets 应用程序的向导只是为了检查 wxWidgets 是否工作。我开始构建项目并向我展示了一些我已纠正的错误。

但我无法得到这些错误:

    ||=== Build: Debug in x (compiler: GNU GCC Compiler) ===|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o||in function `WinMain':|
C:\Users\Aadhish\Documents\Projects\x\xApp.cpp|17|undefined reference to `__imp__Z7wxEntryP11HINSTANCE__S0_Pci'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o||in function `xApp::OnInit()':|
C:\Users\Aadhish\Documents\Projects\x\xApp.cpp|23|undefined reference to `__imp__Z22wxInitAllImageHandlersv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o||in function `xApp::xApp()':|
C:\Users\Aadhish\Documents\Projects\x\xApp.h|15|undefined reference to `__imp__ZN5wxAppC2Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x10)||undefined reference to `wxApp::GetClassInfo() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x80)||undefined reference to `wxApp::GetEventTable() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x88)||undefined reference to `wxApp::GetEventHashTable() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0xb0)||undefined reference to `wxApp::Initialize(int&, wchar_t**)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0xc8)||undefined reference to `wxAppBase::OnRun()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0xe0)||undefined reference to `wxAppBase::OnExit()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0xf0)||undefined reference to `wxApp::CleanUp()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x108)||undefined reference to `wxAppBase::OnInitCmdLine(wxCmdLineParser&)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x110)||undefined reference to `wxAppBase::OnCmdLineParsed(wxCmdLineParser&)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x150)||undefined reference to `wxApp::OnExceptionInMainLoop()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x190)||undefined reference to `wxApp::WakeUpIdle()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x198)||undefined reference to `wxAppBase::ProcessIdle()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1b8)||undefined reference to `wxAppBase::CreateTraits()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1c0)||undefined reference to `wxAppBase::OnInitGui()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1c8)||undefined reference to `wxAppBase::SafeYield(wxWindow*, bool)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1d0)||undefined reference to `wxAppBase::SafeYieldFor(wxWindow*, long)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1e0)||undefined reference to `wxAppBase::GetTopWindow() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1e8)||undefined reference to `wxAppBase::GetDisplayMode() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x200)||undefined reference to `wxAppBase::GetLayoutDirection() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x210)||undefined reference to `wxAppBase::SetActive(bool, wxWindow*)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o||in function `xApp::~xApp()':|
C:\Users\Aadhish\Documents\Projects\x\xApp.h|15|undefined reference to `__imp__ZN5wxAppD2Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `xFrame::xFrame(wxWindow*, int)':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|64|undefined reference to `__imp_wxDefaultSize'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|64|undefined reference to `__imp_wxDefaultPosition'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|64|undefined reference to `__imp__ZN7wxFrame6CreateEP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|65|undefined reference to `__imp__ZN9wxMenuBarC1Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|67|undefined reference to `__imp__ZN10wxMenuItemC1EP6wxMenuiRK8wxStringS4_10wxItemKindS1_'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|71|undefined reference to `__imp__ZN10wxMenuItemC1EP6wxMenuiRK8wxStringS4_10wxItemKindS1_'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|74|undefined reference to `__imp__ZN11wxFrameBase10SetMenuBarEP9wxMenuBar'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|80|undefined reference to `__imp__ZN11wxFrameBase12SetStatusBarEP11wxStatusBar'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|82|undefined reference to `__imp_wxEVT_MENU'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|83|undefined reference to `__imp_wxEVT_MENU'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|55|undefined reference to `__imp__ZN7wxFrameD2Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `xFrame::~xFrame()':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|87|undefined reference to `__imp__ZN7wxFrameD2Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `xFrame::OnQuit(wxCommandEvent&)':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|95|undefined reference to `__imp__ZN12wxWindowBase5CloseEb'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `xFrame::OnAbout(wxCommandEvent&)':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|101|undefined reference to `__imp__Z12wxMessageBoxRK8wxStringS1_lP8wxWindowii'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `__static_initialization_and_destruction_0':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|50|undefined reference to `__imp__ZN7wxFrame13sm_eventTableE'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::GetBestVirtualSize() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|525|undefined reference to `__imp__ZNK12wxWindowBase11GetBestSizeEv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::CanBeFocused() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|738|undefined reference to `__imp__ZNK12wxWindowBase9IsEnabledEv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::HasCapture() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|1032|undefined reference to `__imp__ZN12wxWindowBase10GetCaptureEv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::GetDefaultAttributes() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|1113|undefined reference to `__imp__ZN12wxWindowBase25GetClassDefaultAttributesE15wxWindowVariant'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::DoGetBestClientSize() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|1817|undefined reference to `__imp_wxDefaultSize'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindow::ShowWithEffect(wxShowEffect, unsigned int)':|
C:\MinGW\include\wxwidgets\include\wx\msw\window.h|89|undefined reference to `__imp__ZN8wxWindow17MSWShowWithEffectEb12wxShowEffectj'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindow::HideWithEffect(wxShowEffect, unsigned int)':|
C:\MinGW\include\wxwidgets\include\wx\msw\window.h|94|undefined reference to `__imp__ZN8wxWindow17MSWShowWithEffectEb12wxShowEffectj'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindow::MSWEndDeferWindowPos()':|
C:\MinGW\include\wxwidgets\include\wx\msw\window.h|756|undefined reference to `__imp_wxDefaultPosition'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\MinGW\include\wxwidgets\include\wx\msw\window.h|757|undefined reference to `__imp_wxDefaultSize'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxTopLevelWindowBase::IsActive()':|
C:\MinGW\include\wxwidgets\include\wx\toplevel.h|201|undefined reference to `__imp__ZN12wxWindowBase9FindFocusEv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\MinGW\include\wxwidgets\include\wx\toplevel.h|201|undefined reference to `__imp__ZNK12wxWindowBase12IsDescendantEPS_'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|

我遇到了这些错误。我知道这是图书馆的错误。我链接了 libwxbase31ud.a.

希望我解释了一切。

您有 UI 个元素,因此您至少需要 core 个库(即 libwxmsw31ud_core.a)。 有一个 Library List 页面可能对您有用。然后你可以去你的libwxbase31ud.a当前所在的文件夹,找到每个库对应的文件。

查找库详细信息的另一个好地方是 makefile.gcc wxWidgets 附带的示例。