Menu

#199 Mingw64-i686 CMake can't find wxWidgets

1.0
closed
nobody
None
2017-02-04
2015-10-15
Alex Zelid
No

Mingw32 CMake can't find wxWidgets

CMakeList.txt:

SET(myapp1_SRCS main.cpp)

set(wxWidgets_CONFIGURATION mswu)

find_package( wxWidgets COMPONENTS gl aui adv html core net base xml REQUIRED )

include(${wxWidgets_USE_FILE})

add_executable(${PROJECT_NAME} ${myapp1_SRCS})
target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES})

wxWidgets are installed:

mingw32/mingw-w64-i686-wxWidgets 3.0.2-11 [installed]
    A C++ library that lets developers create applications for Windows, Linux and UNIX (mingw-w64)

Linking manually with wxWidgets works fine:

g++ main.cpp --static `wx-config --libs --static yes` `wx-config --cxxflags --static yes` -o app-static

But CMake's find_package can't find wxWidgets the same time.

Is it MSYS2 bug or I've made something wrong?
Is there any overcome how to make wxWidgets be found by CMake for mingw64-i686 on MSYS2?

Discussion

  • Alexx83

    Alexx83 - 2015-10-15

    You need use "wx-config" to get proper configuration for wxWidgets. Something like:
    https://github.com/eranif/codelite/blob/master/CMakeLists.txt#L92

     
  • Alex Zelid

    Alex Zelid - 2015-10-15

    Alexey, thanks for suggestion. I had few more tries and now I'm a bit confused of mixing ming32 and msys.

    Previously I ran cmake -D CMAKE_CXX_COMPILER=g++.exe -G "MinGW Makefiles" ../master from mingw32_shell.bat

    That made sense for me "MinGW Makefiles" in mingw32_shell and I had this error:

    $ cmake -D CMAKE_CXX_COMPILER=g++.exe -G "MinGW Makefiles" ../master
    -- The C compiler identification is GNU 5.2.0
    -- The CXX compiler identification is GNU 5.2.0
    -- Check for working C compiler: C:/msys64/mingw32/bin/gcc.exe
    -- Check for working C compiler: C:/msys64/mingw32/bin/gcc.exe -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: C:/msys64/mingw32/bin/g++.exe
    -- Check for working CXX compiler: C:/msys64/mingw32/bin/g++.exe -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    CMake Error at C:/msys64/mingw32/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
      Could NOT find wxWidgets (missing: wxWidgets_FOUND)
    Call Stack (most recent call first):
      C:/msys64/mingw32/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
      C:/msys64/mingw32/share/cmake-3.3/Modules/FindwxWidgets.cmake:871 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
      myapp1/CMakeLists.txt:10 (find_package)
    

    When I run cmake -D CMAKE_CXX_COMPILER=g++.exe -G "MSYS Makefiles" ../master from mingw32_shell.bat
    That doesn't make sense from the first glance to run "MSYS Makefiles" from mingw32 shell.
    I get success with CMake wxWidgets finder:

    $ cmake -D CMAKE_CXX_COMPILER=g++.exe -G "MSYS Makefiles" ../master
    -- The C compiler identification is GNU 5.2.0
    -- The CXX compiler identification is GNU 5.2.0
    -- Check for working C compiler: C:/msys64/mingw32/bin/gcc.exe
    -- Check for working C compiler: C:/msys64/mingw32/bin/gcc.exe -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: C:/msys64/mingw32/bin/g++.exe
    -- Check for working CXX compiler: C:/msys64/mingw32/bin/g++.exe -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found wxWidgets: TRUE
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/msys64/home/Alex/workspace/_cmake/wxdemo1/build-msys
    

    But after sucessful generation of "MSYS Makefiles" mingw32-make can't build the project:

    $ mingw32-make
    Scanning dependencies of target wxdemo1
    [ 50%] Building CXX object myapp1/CMakeFiles/wxdemo1.dir/main.cpp.obj
    C:/msys64/home/Alex/workspace/_cmake/wxdemo1/master/myapp1/main.cpp:29:47: fatal error: /mingw32/include/wx-3.0/wx/wxprec.h: No such file or directory
    compilation terminated.
    myapp1/CMakeFiles/wxdemo1.dir/build.make:62: recipe for target 'myapp1/CMakeFiles/wxdemo1.dir/main.cpp.obj' failed
    mingw32-make[2]: *** [myapp1/CMakeFiles/wxdemo1.dir/main.cpp.obj] Error 1
    CMakeFiles/Makefile2:85: recipe for target 'myapp1/CMakeFiles/wxdemo1.dir/all' failed
    mingw32-make[1]: *** [myapp1/CMakeFiles/wxdemo1.dir/all] Error 2
    Makefile:83: recipe for target 'all' failed
    mingw32-make: *** [all] Error 2
    

    So the strange things:
    1) CMake can't generate "MinGW Makefiles" from ming32_shell
    2) But it can generate "MSYS Makefiles" from mingw32_shell
    3) Generated "MSYS Makefiles" doesn't build with mingw32-make from mingw32_shell

     

    Last edit: Alex Zelid 2015-10-15
  • Alexx83

    Alexx83 - 2015-10-15

    Generating "MinGW Makefiles" are needed only when you use "mingw32-make" not "make". Usually it need only when you run cmake from CMD instead MSYS2 shell.
    "MinGW Makefiles" use some different syntax than regular Makefiles.

    You MUST run "make" not "mingw32-make" for Makefiles generated with "MSYS Makefiles"

     
  • Alex Zelid

    Alex Zelid - 2015-10-16

    Generating CMAke's "MSYS Makefiles" + running "make" instead of "mingw32-make" from mingw32_shell solved all things! Now everything works.

    Firstly I thought by mistake that "MSYS Makefiles" or "make" will link with MSYS runtime that I tried to avoid.

    Thanks a lot, Alexey!

     

    Last edit: Alex Zelid 2015-10-16
  • Alex Zelid

    Alex Zelid - 2015-10-16

    Everything worked... fine to build in msys2 shell. But when you try to use mingw32-make in IDE (to debug your own program that is linked with wxWidgets) - you get the same error again because IDE doesn't understand msys2 shell

    Is there any IDE (CodeLite, CLion, Code::Blocks, qtCreator, NetBeans, other...) that can debug project like inside msys2?

    Or any other IDE configuration that will allow CMake to find wxWidgets and also allow project to work with any IDE the same time?

     
  • David Macek

    David Macek - 2017-02-04
    • status: open --> closed
     
  • David Macek

    David Macek - 2017-02-04

    Closing due to age. Please file an issue on GitHub if still relevant.