When linking a project using wxWidgets with Cmake,

undefined reference to `_imp__InitCommonControls @ 0 '

This is going to be on Ubuntu under Windows using mingw32-w64, wxWidgets is pre-compiled by mingw and lies along the path /usr/lib/wx-3.1-win

From there directly and take the core and base libraries, but in some miraculous way from

libwx_mswu_core-3.1-i686-w64-mingw32.a (corelib_msw_app.o)

complains that there is no reference to the function (that is, the library with its implementation is not connected), and considering this, I include libcomctl32.a

Cmake content is as follows

include_directories(/usr/lib/wx-3.1-win/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.1 /usr/lib/wx-3.1-win/include/wx-3.1) add_executable (welcome ${src}) #${core_src}) target_link_libraries(welcome /usr/i686-w64-mingw32/lib/libcomctl32.a /usr/lib/wx-3.1-win/lib/libwx_mswu_core-3.1-i686-w64-mingw32.a /usr/lib/wx-3.1-win/lib/libwx_baseu-3.1-i686-w64-mingw32.a ) 

But in the end I have all the same hundreds of undefined reference. How to fix it and why if a library is connected for _imp__InitCommonControls@0 , does the error remain?

UPD:

The library has such a function: enter image description here

  • _imp__InitCommonControls @ 0 and _imp__InitCommonControls are different characters. I would look through nm which symbol is needed in the problem object and which one is in the slipped lib. Well, along the way, I would search for the lib with the desired symbol. But why can't I say so ... - Vladimir Martyanov
  • @ VladimirMartiyanov There is such a function in the library, and it is connected (added screen) - Ni55aN
  • Moved the core and baseu to the first place, now does not complain about the functions of those libs that are connected, it turns out they need to be placed so that the first are the libraries that use the following? - Ni55aN
  • It is very likely that order matters. Someone here told me about cygwin that there is so. But I don’t know much about mingw and cygwin ... - Vladimir Martyanov

1 answer 1

When connecting libraries, it is important to first connect the libraries libwx_... and after them libcomctl32.a and others.

It turned out that for wx you need libraries:

 /usr/lib/wx-3.1-win/lib/libwx_mswu_core-3.1-i686-w64-mingw32.a /usr/lib/wx-3.1-win/lib/libwx_baseu-3.1-i686-w64-mingw32.a /usr/lib/wx-3.1-win/lib/libwxpng-3.1-i686-w64-mingw32.a /usr/lib/wx-3.1-win/lib/libwxzlib-3.1-i686-w64-mingw32.a libmingw32.a libcomctl32.a libcomdlg32.a libole32.a liboleaut32.a libshlwapi.a libuuid.a libversion.a libwinspool.a libgdi32.a