How do I use wxWidgets with Mingw-W64 and CLion?

偶尔善良 提交于 2020-12-15 11:59:20

问题


When attempting to build the wxWidgets (3.0.5) library with MinGW-W64 (x86-64) GCC 8.1.0, I get the following output:

wxWidgets-3.0.5\build\msw> mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug -j4
if not exist gcc_mswuddll mkdir gcc_mswuddll
if not exist ..\..\lib\gcc_dll mkdir ..\..\lib\gcc_dll
if not exist ..\..\lib\gcc_dll\mswud\wx\setup.h copy ..\..\include\wx\msw\setup.h ..\..\lib\gcc_dll\mswud\wx\setup.h
gcc -c -o gcc_mswuddll\wxregex_regcomp.o -g -O0 -mthreads  -DHAVE_W32API_H -DNDEBUG -I..\..\include -I..\..\lib\gcc_dll\mswud -D__WXMSW__  -D_UNICODE   -MTgcc_mswuddll\wxregex_regcomp.o -MFgcc_mswuddll\wxregex_regcomp.o.d -MD -MP ../../src/regex/regcomp.c
gcc -c -o gcc_mswuddll\wxregex_regexec.o -g -O0 -mthreads  -DHAVE_W32API_H -DNDEBUG -I..\..\include -I..\..\lib\gcc_dll\mswud -D__WXMSW__  -D_UNICODE   -MTgcc_mswuddll\wxregex_regexec.o -MFgcc_mswuddll\wxregex_regexec.o.d -MD -MP ../../src/regex/regexec.c
gcc -c -o gcc_mswuddll\wxregex_regerror.o -g -O0 -mthreads  -DHAVE_W32API_H -DNDEBUG -I..\..\include -I..\..\lib\gcc_dll\mswud -D__WXMSW__  -D_UNICODE   -MTgcc_mswuddll\wxregex_regerror.o -MFgcc_mswuddll\wxregex_regerror.o.d -MD -MP ../../src/regex/regerror.c
The system cannot find the path specified.
        0 file(s) copied.
mingw32-make: *** [makefile.gcc:5651: ..\..\lib\gcc_dll\mswud\wx\setup.h] Error 1
mingw32-make: *** Waiting for unfinished jobs....
In file included from In file included from In file included from ..\..\include/wx/defs.h:27..\..\include/wx/defs.h:27                                                                                                  from ,
                 from ,
                 from                               ../../src/regex/regcustom.h:39                                                                                                                                      from ,
                 from ,
                 from                             ../../src/regex/regguts.h:38                                                                                                                                          from ,
                 from ,
                 from                             ../../src/regex/regexec.c:32                                                                                                                         :
:
                                   ..\..\include/wx/platform.h:183:10:                                                   fatal error:                                                                   #include wx/setup.h: No such file or directory
 #include wx/setup.h: No such file or directory
 #include             "wx/setup.h"                                                                                                                                                                     
                                                                                                                                                                                                                 ^~~~~~~~~~~~
                                                                                                                                                                                                       cc
oocmpomimplpiialtalitoainot ni totener rmtmieinrnamatitenedad.t.
e
d.
mingw32-make: *** [makefile.gcc:5702: gcc_mswuddll\wxregex_regcomp.o] Error 1
mingw32-make: *** [makefile.gcc:5705: gcc_mswuddll\wxregex_regexec.o] Error 1
mingw32-make: *** [makefile.gcc:5708: gcc_mswuddll\wxregex_regerror.o] Error 1

Similar problems when I set BUILD=release

When I copy setup.h from wxWidgets-3.0.5\include\wx\msw\ to wxWidgets-3.0.5\lib\gcc_dll\mswu\wx\, the errors seem to go away.

However, when I attempt to build this very basic app in CLion (2020.1.1), I get the following errors:

#include <iostream>
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
====================[ Build | app | Debug ]=================================
CLion\ch-0\201.7223.86\bin\cmake\win\bin\cmake.exe --build app\cmake-build-debug --target app -- -j 8
Scanning dependencies of target app
[ 50%] Building CXX object CMakeFiles/app.dir/main.cpp.obj
In file included from wxWidgets-3.0.5/include/wx/defs.h:27,
                 from wxWidgets-3.0.5/include/wx/wxprec.h:12,
                 from app\main.cpp:2:
wxWidgets-3.0.5/include/wx/platform.h:183:10: fatal error: wx/setup.h: No such file or directory
 #include "wx/setup.h"
          ^~~~~~~~~~~~
compilation terminated.
mingw32-make.exe[3]: *** [CMakeFiles\app.dir\build.make:63: CMakeFiles/app.dir/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:75: CMakeFiles/app.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/app.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: app] Error 2

Here is the CMakeLists.txt file (debug version):

cmake_minimum_required(VERSION 3.16)
project(app)

set(CMAKE_CXX_STANDARD 14)
include_directories(
        includes
        wxWidgets-3.0.5
        wxWidgets-3.0.5/include
        wxWidgets-3.0.5/include/msvc/wx
        wxWidgets-3.0.5/lib/gcc_lib/mswu
)
link_directories(
        wxWidgets-3.0.5/lib/gcc_lib
)

set(
        WX_LIBS
        libwxmsw30ud_propgrid.a
        libwxmsw30ud_ribbon.a
        libwxmsw30ud_stc.a
        libwxmsw30ud_webview.a
        libwxmsw30ud_gl.a
        libwxmsw30ud_richtext.a
        libwxmsw30ud_xrc.a
        libwxmsw30ud_aui.a
        libwxmsw30ud_html.a
        libwxmsw30ud_adv.a
        libwxmsw30ud_core.a
        libwxbase30ud_xml.a
        libwxbase30ud_net.a
        libwxbase30ud.a
        libwxscintillad.a
        libwxtiffd.a
        libwxjpegd.a
        libwxpngd.a
        libwxzlibd.a
        libwxregexud.a
        libwxexpatd.a
        libwxmsw30ud_media.a
)

set(SOURCE_FILES aui.cpp)
add_executable(app main.cpp)
target_link_libraries(
        app
        ${WX_LIBS}
#        -lcomctl32
)

Can anyone tell me what is causing these problems?


Update #1:

Now using wxWidgets 3.1.3.

New contents of main.cpp:

#include <iostream>
#include <wx/wxprec.h>

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

class MyApp : public wxApp {
public:
    virtual bool OnInit();
};

class MyFrame : public wxFrame {
public:
    MyFrame(const wxString &title, const wxPoint &pos, const wxSize &size);

private:
    void OnHello(wxCommandEvent &event);
    void OnExit(wxCommandEvent &event);
    void OnAbout(wxCommandEvent &event);

wxDECLARE_EVENT_TABLE();
};

enum {
    ID_Hello = 1
};

wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
                EVT_MENU(ID_Hello, MyFrame::OnHello)
                EVT_MENU(wxID_EXIT, MyFrame::OnExit)
                EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
wxEND_EVENT_TABLE()

wxIMPLEMENT_APP(MyApp);
/* This is what the macro expands to: */
/* extern "C" int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wxCmdLineArgType, int nCmdShow) {
    ;;
    return wxEntry(hInstance, hPrevInstance, 0, nCmdShow);
}
MyApp &wxGetApp() { return *static_cast<MyApp *>(wxApp::GetInstance()); }
wxAppConsole *wxCreateApp() {
    wxAppConsole::CheckBuildOptions(
            "3" "." "1" "." "3" " (" "wchar_t" ",Visual C++ " "1900" ",wx containers" ",compatible with 3.0" ")",
            "your program");
    return new MyApp;
}

wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp)
 */

bool MyApp::OnInit() {
    MyFrame *frame = new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340));
    frame->Show(true);
    return true;
}

MyFrame::MyFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
        : wxFrame(NULL, wxID_ANY, title, pos, size) {
    wxMenu *menuFile = new wxMenu;
    menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
                     "Help string shown in status bar for this menu item");
    menuFile->AppendSeparator();
    menuFile->Append(wxID_EXIT);
    wxMenu *menuHelp = new wxMenu;
    menuHelp->Append(wxID_ABOUT);
    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append(menuFile, "&File");
    menuBar->Append(menuHelp, "&Help");
    SetMenuBar(menuBar);
    CreateStatusBar();
    SetStatusText("Welcome to wxWidgets!");
}

void MyFrame::OnExit(wxCommandEvent &event) {
    Close(true);
}

void MyFrame::OnAbout(wxCommandEvent &event) {
    wxMessageBox("This is a wxWidgets' Hello world sample",
                 "About Hello World", wxOK | wxICON_INFORMATION);
}

void MyFrame::OnHello(wxCommandEvent &event) {
    wxLogMessage("Hello world from wxWidgets!");
}


/*int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}*/

New contents of the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.16)
project(HelloWorld)

set(CMAKE_CXX_STANDARD 14)
set(SRC_FILES
    main.cpp
    )

add_link_options(LINKER: UNICODE=1)
add_link_options(LINKER: BUILD=debug)

include_directories(
    includes
    E:/cpp/lib/wxWidgets-3.1.3
    E:/cpp/lib/wxWidgets-3.1.3/include
    E:/cpp/lib/wxWidgets-3.1.3/include/msvc
    E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx
    E:/cpp/lib/wxWidgets-3.1.3/lib/gcc_lib/mswud
)
link_directories(
    E:/cpp/Lib/wxWin/lib/vc14x_x64_dll
)

add_executable(${PROJECT_NAME} ${SRC_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES
    LINK_FLAGS /SUBSYSTEM:WINDOWS
    )

After adding wxWidgets-3.0.5/include/msvc to the include_directories list, I get the following errors:

In file included from E:/cpp/lib/wxWidgets-3.1.3/include/wx/platform.h:154,
                 from E:/cpp/lib/wxWidgets-3.1.3/include/wx/defs.h:45,
                 from E:/cpp/lib/wxWidgets-3.1.3/include/wx/wxprec.h:12,
                 from E:\cpp\dev\HelloWorld\main.cpp:2:
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:12:6: error: #error "This file should only be included when using Microsoft Visual C++"
     #error "This file should only be included when using Microsoft Visual C++"
      ^~~~~
In file included from E:/cpp/lib/wxWidgets-3.1.3/include/wx/version.h:16,
                 from E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:19,
                 from E:/cpp/lib/wxWidgets-3.1.3/include/wx/platform.h:154,
                 from E:/cpp/lib/wxWidgets-3.1.3/include/wx/defs.h:45,
                 from E:/cpp/lib/wxWidgets-3.1.3/include/wx/wxprec.h:12,
                 from E:\cpp\dev\HelloWorld\main.cpp:2:
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:135:31: error: pasting "/" and "vc_x64_lib" does not give a valid preprocessing token
         wxCONCAT5(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, /wx/setup.h)
                               ^
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:18:37: note: in definition of macro 'wxCONCAT_HELPER'
 #define wxCONCAT_HELPER(text, line) text ## line
                                     ^~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:23:14: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT(x1, x2), x3)
              ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:25:14: note: in expansion of macro 'wxCONCAT3'
     wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
              ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:27:14: note: in expansion of macro 'wxCONCAT4'
     wxCONCAT(wxCONCAT4(x1, x2, x3, x4), x5)
              ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:135:9: note: in expansion of macro 'wxCONCAT5'
         wxCONCAT5(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, /wx/setup.h)
         ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:138:39: note: in expansion of macro 'wxSETUPH_PATH'
 #define wxSETUPH_PATH_STR wxSTRINGIZE(wxSETUPH_PATH)
                                       ^~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:140:10: note: in expansion of macro 'wxSETUPH_PATH_STR'
 #include wxSETUPH_PATH_STR
          ^~~~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:89:31: error: pasting "vc_x64_lib" and "/" does not give a valid preprocessing token
     #define wxCOMPILER_PREFIX vc
                               ^~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:18:37: note: in definition of macro 'wxCONCAT_HELPER'
 #define wxCONCAT_HELPER(text, line) text ## line
                                     ^~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:23:5: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT(x1, x2), x3)
     ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:21:5: note: in expansion of macro 'wxCONCAT_HELPER'
     wxCONCAT_HELPER(x1, x2)
     ^~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:23:14: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT(x1, x2), x3)
              ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:25:14: note: in expansion of macro 'wxCONCAT3'
     wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
              ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:27:14: note: in expansion of macro 'wxCONCAT4'
     wxCONCAT(wxCONCAT4(x1, x2, x3, x4), x5)
              ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:135:9: note: in expansion of macro 'wxCONCAT5'
         wxCONCAT5(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, /wx/setup.h)
         ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:21:5: note: in expansion of macro 'wxCONCAT_HELPER'
     wxCONCAT_HELPER(x1, x2)
     ^~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:25:5: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
     ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:21:5: note: in expansion of macro 'wxCONCAT_HELPER'
     wxCONCAT_HELPER(x1, x2)
     ^~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:23:5: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT(x1, x2), x3)
     ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:21:5: note: in expansion of macro 'wxCONCAT_HELPER'
     wxCONCAT_HELPER(x1, x2)
     ^~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:23:14: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT(x1, x2), x3)
              ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:25:14: note: in expansion of macro 'wxCONCAT3'
     wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
              ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:115:9: note: in expansion of macro 'wxCONCAT4'
         wxCONCAT4(wxCOMPILER_PREFIX, wxARCH_SUFFIX, _lib, wxCFG)
         ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:115:19: note: in expansion of macro 'wxCOMPILER_PREFIX'
         wxCONCAT4(wxCOMPILER_PREFIX, wxARCH_SUFFIX, _lib, wxCFG)
                   ^~~~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:135:34: note: in expansion of macro 'wxLIB_SUBDIR'
         wxCONCAT5(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, /wx/setup.h)
                                  ^~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:138:39: note: in expansion of macro 'wxSETUPH_PATH'
 #define wxSETUPH_PATH_STR wxSTRINGIZE(wxSETUPH_PATH)
                                       ^~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:140:10: note: in expansion of macro 'wxSETUPH_PATH_STR'
 #include wxSETUPH_PATH_STR
          ^~~~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:135:48: error: pasting "/" and "msw" does not give a valid preprocessing token
         wxCONCAT5(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, /wx/setup.h)
                                                ^
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:18:37: note: in definition of macro 'wxCONCAT_HELPER'
 #define wxCONCAT_HELPER(text, line) text ## line
                                     ^~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:25:5: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
     ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:21:5: note: in expansion of macro 'wxCONCAT_HELPER'
     wxCONCAT_HELPER(x1, x2)
     ^~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:23:5: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT(x1, x2), x3)
     ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:25:14: note: in expansion of macro 'wxCONCAT3'
     wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
              ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:27:14: note: in expansion of macro 'wxCONCAT4'
     wxCONCAT(wxCONCAT4(x1, x2, x3, x4), x5)
              ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:135:9: note: in expansion of macro 'wxCONCAT5'
         wxCONCAT5(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, /wx/setup.h)
         ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:138:39: note: in expansion of macro 'wxSETUPH_PATH'
 #define wxSETUPH_PATH_STR wxSTRINGIZE(wxSETUPH_PATH)
                                       ^~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:140:10: note: in expansion of macro 'wxSETUPH_PATH_STR'
 #include wxSETUPH_PATH_STR
          ^~~~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:124:34: error: pasting "msw" and "/" does not give a valid preprocessing token
         #define wxTOOLKIT_PREFIX msw
                                  ^~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:18:37: note: in definition of macro 'wxCONCAT_HELPER'
 #define wxCONCAT_HELPER(text, line) text ## line
                                     ^~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:27:5: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT4(x1, x2, x3, x4), x5)
     ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:21:5: note: in expansion of macro 'wxCONCAT_HELPER'
     wxCONCAT_HELPER(x1, x2)
     ^~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:25:5: note: in expansion of macro 'wxCONCAT'
     wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
     ^~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/wx/cpp.h:27:14: note: in expansion of macro 'wxCONCAT4'
     wxCONCAT(wxCONCAT4(x1, x2, x3, x4), x5)
              ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:135:9: note: in expansion of macro 'wxCONCAT5'
         wxCONCAT5(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, /wx/setup.h)
         ^~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:135:51: note: in expansion of macro 'wxTOOLKIT_PREFIX'
         wxCONCAT5(../../../lib/, wxLIB_SUBDIR, /, wxTOOLKIT_PREFIX, /wx/setup.h)
                                                   ^~~~~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:138:39: note: in expansion of macro 'wxSETUPH_PATH'
 #define wxSETUPH_PATH_STR wxSTRINGIZE(wxSETUPH_PATH)
                                       ^~~~~~~~~~~~~
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:140:10: note: in expansion of macro 'wxSETUPH_PATH_STR'
 #include wxSETUPH_PATH_STR
          ^~~~~~~~~~~~~~~~~
In file included from E:/cpp/lib/wxWidgets-3.1.3/include/wx/platform.h:154,
                 from E:/cpp/lib/wxWidgets-3.1.3/include/wx/defs.h:45,
                 from E:/cpp/lib/wxWidgets-3.1.3/include/wx/wxprec.h:12,
                 from E:\cpp\dev\HelloWorld\main.cpp:2:
E:/cpp/lib/wxWidgets-3.1.3/include/msvc/wx/setup.h:140:1: fatal error: ../../../lib/vc_x64_lib /msw /wx/setup.h: No such file or directory
 #include wxSETUPH_PATH_STR
 ^~~
compilation terminated.
mingw32-make.exe[3]: *** [CMakeFiles\HelloWorld.dir\build.make:66: CMakeFiles/HelloWorld.dir/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:78: CMakeFiles/HelloWorld.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:85: CMakeFiles/HelloWorld.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:120: HelloWorld] Error 2

Update #2:

With the possibility there could — or, should — be a different setup.h file to use, I analyzed the wxWidgets\3.1.3\build\msw\makefile.gcc file, these two lines are found, starting at line 5872:

..\..\include\wx\$(__SETUP_H_SUBDIR_FILENAMES)\setup.h: 
    if not exist ..\..\include\wx\$(__SETUP_H_SUBDIR_FILENAMES)\setup.h copy ..\..\include\wx\$(__SETUP_H_SUBDIR_FILENAMES)\setup0.h ..\..\include\wx\$(__SETUP_H_SUBDIR_FILENAMES)\setup.h

I did a search on setup0.h, did a search on a fresh unzip of the archive, and found nothing. Is the a ghost file?

Could this be it? Found on wxWidgets's GitHub repository?


回答1:


SOLVED!

Problems solved by locating the correct setup.h file — found on GitHub.

Updated cmakelists.txt to this:

cmake_minimum_required(VERSION 3.16)

project(HelloWorld)

set(CMAKE_CXX_STANDARD 14)

set(SRC_FILES
    main.cpp
    )

include_directories(
    includes
    E:/cpp/lib/wxWidgets-3.1.3
    E:/cpp/lib/wxWidgets-3.1.3/include
    E:/cpp/lib/wxWidgets-3.1.3/lib/gcc_dll/mswud
)

link_directories(
    E:/cpp/lib/wxWidgets-3.1.3/lib/gcc_dll
    E:/cpp/lib/wxWidgets-3.1.3/lib/gcc_dll/mswud
)

set(
    WX_LIBS
    libwxmsw31ud_propgrid.a
    libwxmsw31ud_ribbon.a
    libwxmsw31ud_stc.a
    libwxmsw31ud_webview.a
    libwxmsw31ud_gl.a
    libwxmsw31ud_richtext.a
    libwxmsw31ud_xrc.a
    libwxmsw31ud_aui.a
    libwxmsw31ud_html.a
    libwxmsw31ud_adv.a
    libwxmsw31ud_core.a
    libwxbase31ud_xml.a
    libwxbase31ud_net.a
    libwxbase31ud.a
    libwxscintillad.a
    libwxtiffd.a
    libwxjpegd.a
    libwxpngd.a
    libwxzlibd.a
    libwxregexud.a
    libwxexpatd.a
    libwxmsw31ud_media.a
)

add_executable(${PROJECT_NAME} ${SRC_FILES})

target_link_libraries(
    ${PROJECT_NAME}
    ${WX_LIBS}
)


来源:https://stackoverflow.com/questions/61716701/how-do-i-use-wxwidgets-with-mingw-w64-and-clion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!