Compilation fails due to "_imp_"s

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
DarthMeow
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Nov 08, 2019 6:32 am

Compilation fails due to "_imp_"s

Post by DarthMeow » Fri Nov 08, 2019 6:40 am

Hello, I am new to wxWidgets, mostly spent my time programming in Java and Python, in other IDEs. Anyways, I am trying to create a simple program and it seems that I cannot compile it because of problems with linking. What could possibly cause these errors?

I am using the MinGW compiler packaged with Code::Blocks, and I am using wxWidgets binaries. They are properly set up, and I don't think that I am missing any files.

Thiis is the error.

Code: Select all

||=== Build: Release in Build1 (compiler: GNU GCC Compiler) ===|
obj\Release\Build1App.o:Build1App.cpp|| undefined reference to `_imp___ZN16wxAppConsoleBase17CheckBuildOptionsEPKcS1_'|
obj\Release\Build1App.o:Build1App.cpp|| undefined reference to `_imp___ZN5wxAppC2Ev'|
obj\Release\Build1App.o:Build1App.cpp|| undefined reference to `_imp___Z7wxEntryP11HINSTANCE__S0_Pci'|
obj\Release\Build1App.o:Build1App.cpp|| undefined reference to `_imp___ZN16wxAppConsoleBase14ms_appInstanceE'|
obj\Release\Build1App.o:Build1App.cpp|| undefined reference to `_imp___Z22wxInitAllImageHandlersv'|
obj\Release\Build1App.o:Build1App.cpp|| undefined reference to `_imp___ZN19wxTopLevelWindowMSW4ShowEb'|
||error: ld returned 1 exit status|
||=== Build failed: 7 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
I saw a few threads about these imps, but the solutions don't seem to agree with me.

User avatar
doublemax
Moderator
Moderator
Posts: 14305
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compilation fails due to "_imp_"s

Post by doublemax » Fri Nov 08, 2019 7:26 am

MinGW compiler packaged with Code::Blocks, and I am using wxWidgets binaries
Which binaries? On the wxWidgets download page i only see binaries for MinGW 7.3 and 8.1. AFAIK CodeBlocks comes with an older 5.1.

Try switching the compiler to one of those, or try building wxWidgets from scratch. Here's a complete step-by-step tutorial:
viewtopic.php?f=19&t=46125
Use the source, Luke!

DarthMeow
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Nov 08, 2019 6:32 am

Re: Compilation fails due to "_imp_"s

Post by DarthMeow » Fri Nov 08, 2019 12:07 pm

Updated my MinGW installation to 8.1.0, changed everything in the configurations, now it compiles like this:

Code: Select all

||=== Build: Debug in Build1 (compiler: GNU GCC Compiler) ===|
obj\Debug\Build1App.o||In function `WinMain':|
C:\Users\Cianne\Documents\Build1\Build1App.cpp|18|undefined reference to `__imp__Z7wxEntryP11HINSTANCE__S0_Pci'|
obj\Debug\Build1App.o||In function `wxCreateApp()':|
C:\Users\Cianne\Documents\Build1\Build1App.cpp|18|undefined reference to `__imp__ZN16wxAppConsoleBase17CheckBuildOptionsEPKcS1_'|
obj\Debug\Build1App.o||In function `Build1App::OnInit()':|
C:\Users\Cianne\Documents\Build1\Build1App.cpp|24|undefined reference to `__imp__Z22wxInitAllImageHandlersv'|
obj\Debug\Build1App.o||In function `wxAppConsoleBase::SetInitializerFunction(wxAppConsole* (*)())':|
D:\backup\wx\include\wx\app.h|454|undefined reference to `__imp__ZN16wxAppConsoleBase12ms_appInitFnE'|
obj\Debug\Build1App.o||In function `wxAppConsoleBase::GetInstance()':|
D:\backup\wx\include\wx\app.h|462|undefined reference to `__imp__ZN16wxAppConsoleBase14ms_appInstanceE'|
obj\Debug\Build1App.o||In function `Build1App::Build1App()':|
C:\Users\Cianne\Documents\Build1\Build1App.h|15|undefined reference to `__imp__ZN5wxAppC2Ev'|
obj\Debug\Build1App.o:Build1App.cpp:(.rdata$_ZTV9Build1App[_ZTV9Build1App]+0x10)||undefined reference to `wxApp::GetClassInfo() const'|
obj\Debug\Build1App.o:Build1App.cpp:(.rdata$_ZTV9Build1App[_ZTV9Build1App]+0x28)||undefined reference to `wxObject::CreateRefData() const'|
obj\Debug\Build1App.o:Build1App.cpp:(.rdata$_ZTV9Build1App[_ZTV9Build1App]+0x30)||undefined reference to `wxObject::CloneRefData(wxRefCounter const*) const'|
||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), 3 second(s)) ===|
Thoughts?

User avatar
doublemax
Moderator
Moderator
Posts: 14305
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compilation fails due to "_imp_"s

Post by doublemax » Fri Nov 08, 2019 12:45 pm

Looks like all the wxWidgets libraries are missing in the linker settings. This is all described in the link i posted.

I still recommend to build wxWidgets and the "minimal" sample that comes with it from scratch before using CodeBlocks. Then you know everything is ok on the compiler and wx side and all problems are caused by CB configuration.
Use the source, Luke!

Post Reply