Unable to build MathGL with wxWidgets on Windows using MinGW-w64

95 views
Skip to first unread message

Evgeniy Kishov

unread,
Jul 5, 2022, 6:44:20 AM7/5/22
to MathGL
Hello, 

I've installed MinGW-w64 dev. tools and wxWidgets using MSYS2. Test applications with wxWidgets compile and build well (I use the Code::Blocks). Now I'm trying to link MathGL to my program but without any success. I'm trying to build MathGL using enable-wx option in Cmake. See full error log from cmake below:

Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS)

CMake Error at CMakeLists.txt:680 (message):

Couldn't find wxWidgets library.

Entering C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x/src

Returning to C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x

Entering C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x/widgets

wxWidgets requested but not found.

Entering C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x/widgets/qt5

Returning to C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x/widgets

Returning to C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x

Entering C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x/include

Returning to C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x

Entering C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x/utils

Returning to C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x

Entering C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x/examples

wxWidgets requested but not found.

Returning to C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x

Entering C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x/mgllab

Returning to C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x

Entering C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x/scripts

Returning to C:/Users/eakis/Desktop/mathgl-code-r1716/mathgl-2x

Configuring incomplete, errors occurred!

See also "C:/Users/eakis/Desktop/mathgl-code-r1716/release_build/CMakeFiles/CMakeOutput.log".

See also "C:/Users/eakis/Desktop/mathgl-code-r1716/release_build/CMakeFiles/CMakeError.log".

What I'm doing wrong? 


--

Thanks,

Evgeniy

mathgl....@gmail.com

unread,
Jul 5, 2022, 6:48:02 AM7/5/22
to mat...@googlegroups.com
Dear Evgeiy,

Cmake wrote "Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS)". So, you need to provide proper paths for WX libraries (in wxWidgets_LIBRARIES) and include (in wxWidgets_INCLUDE_DIRS) directories.

вт, 5 июл. 2022 г. в 13:44, Evgeniy Kishov <eaki...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "MathGL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathgl+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathgl/b3617f22-584c-43dd-af5e-3f6bb3e940efn%40googlegroups.com.


--
Kind regards,
Alexey Balakin

Evgeniy Kishov

unread,
Jul 5, 2022, 3:24:16 PM7/5/22
to MathGL
Dear Alexey, 

First of all, thank you for the feedback! 

I understand that I need to specify non-standard path to "lib" and "include" directory of wx. But I don't know exactly how. If I simply declare two additional entries in CMakeLists.txt like
if(enable-wx)
    set(MGL_HAVE_WX 1)
    #my path to compiled wx libraries
    set(wxWidgets_LIBRARIES "C:/msys64/mingw64/bin")
    #my path to wx include dir
    set(wxWidgets_INCLUDE_DIRS "C:/msys64/mingw64/include/wx-3.1")
    FIND_PACKAGE(wxWidgets COMPONENTS base core gl)
    if(NOT wxWidgets_FOUND)
        message(SEND_ERROR "Couldn't find wxWidgets library.")
    endif(NOT wxWidgets_FOUND)
else(enable-wx)
    set(MGL_HAVE_WX 0)
endif(enable-wx)


nothing occures and error stays.

Usually while building my program with wx I use "ws-config-msys2" utility for auto-generation of compiler flags and linking options for g++. If I use output of that utility as content for wxWidgets_LIBRARIES and wxWidgets_INCLUDE_DIRS like
set(wxWidgets_LIBRARIES "-LC:/msys64/mingw64/lib -pipe -lwx_mswu_xrc-3.1 -lwx_mswu_webview-3.1 -lwx_mswu_html-3.1 -lwx_mswu_qa-3.1 -lwx_mswu_adv-3.1 -lwx_mswu_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1 -lwx_mswu_gl-3.1")
set(wxWidgets_INCLUDE_DIRS "-IC:/msys64/mingw64/lib/wx/include/msw-unicode-3.1 -IC:/msys64/mingw64/include/wx-3.1 -mthreads -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMSW__ -DHAVE_W32API_H -D_UNICODE -fmessage-length=0 -pipe")


also there is no success.

I'm newbie in Cmake, Makefiles and all that stuff. I came to MinGW-world from Visual Studio where all build process was automated via IDE. May be I completely misunderstand how the CMake works so excuse me, please. But I really wants to know how to use 3rd-party libraries like MathGL in order to don't reinvent the wheel.

Any help will be highly appreciated.
--
Regards,
Evgeniy

Evgeniy Kishov

unread,
Jul 8, 2022, 3:26:38 PM7/8/22
to MathGL
I solved the problem.

Generally speaking the problem was in fact that CMake macro FIND_PACKAGE "don't understand" usage of the Linux compiler (g++ from MinGW) on Windows. The FIND_PACKAGE macro goes to Unix branch and provide incorrect from Windows point of view paths for wxWidgets.

I've manually edited the FIND_PACKAGE macro (C:\msys64\mingw64\share\cmake\Modules\FindwxWidgets.cmake) the following way:
1) Removed the "sh" entry from all "execute_process" invokations where the wx-config utility launch.
2) File name of wx-config utility changed to wx-config-msys2 using following command:
STRING(REGEX REPLACE "wx-config" "wx-config-msys2" wxWidgets_CONFIG_EXECUTABLE ${wxWidgets_CONFIG_EXECUTABLE})

Also it's necessary to add a command
set(wxWidgets_CONFIG_OPTIONS "--prefix=C:/msys64/mingw64")
to CMakeLists.txt of MathGL library before FIND_PACKAGE invokation.

After mentioned modifications of CMake scripts the MathGL library was sucessfully built with wxWidgets support and MathGL wx-example was sucessfully run.

See modified CMake scripts in attachment. I think it may be useful for community who works with MSYS2-MinGW under Windows.

--
Regards,
Evgeniy
CMakeLists.txt
FindwxWidgets.cmake
Reply all
Reply to author
Forward
0 new messages