Search code examples
codeblockswxwidgets

Undefined refrence with wxWidgets in Code::Blocks


I have downloaded the pre-built binaries of wxWidgets 3.1.2 and placed it in my minGW folder. In Code::Blocks I run the wizard for creating the wxWidgets application just to check whether the wxWidgets is working. I started building the project and showed me some series of errors I rectified it.

But I couldn't get these errors:

    ||=== Build: Debug in x (compiler: GNU GCC Compiler) ===|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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\8.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)) ===|

I got these error. I know it's the error with libraries. I linked the libwxbase31ud.a.

Hope I explained everything.


Solution

  • You have UI elements so you need at least core library too (i.e. libwxmsw31ud_core.a). There is a Library List page that you might find useful. And you can go to the folder where your libwxbase31ud.a currently is, to find the corresponding file for each library.

    Another good place to look for lib details is the makefile.gcc of a sample that comes with wxWidgets.