Z
Z
Zadavatel_Voprosov2018-07-14 18:05:13
C++ / C#
Zadavatel_Voprosov, 2018-07-14 18:05:13

How to make friends wxWidgets and CLion (Windows + mingw-w64)?

Hello! I want to make a GUI application and chose C (without ++) and wxWidgets for this. I downloaded the installer from offsite , installed it (I installed it in C:\wxWidgets-3.1.1).
I thought that was all, but no, when I try to compile, I get an error that there is no library.

Error, CMakeLists.txt and code
"C:\Program Files\JetBrains\CLion 2018.1.5\bin\cmake\bin\cmake.exe" --build C:\Users\Timoshka-WIN10\Documents\CLionProjects\GuiTEST\cmake-build-debug --target GuiTEST -- -j 1
[ 50%] Building C object CMakeFiles/GuiTEST.dir/main.c.obj
C:\Users\Timoshka-WIN10\Documents\CLionProjects\GuiTEST\main.c:3:10: fatal error: wx/wxprec.h: No such file or directory
 #include <wx/wxprec.h>
          ^~~~~~~~~~~~~
compilation terminated.
mingw32-make.exe[3]: *** [CMakeFiles\GuiTEST.dir\build.make:62: CMakeFiles/GuiTEST.dir/main.c.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:67: CMakeFiles/GuiTEST.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:79: CMakeFiles/GuiTEST.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: GuiTEST] Error 2

cmake_minimum_required(VERSION 3.10)
project(GuiTEST C)

set(CMAKE_C_STANDARD 11)

add_executable(GuiTEST main.c)

Код с офф.сайта wxWidgets
// wxWidgets "Hello World" Program
// For compilers that support precompilation, includes "wx/wx.h".
#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();
private:
    void OnHello(wxCommandEvent& event);
    void OnExit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
};
enum
{
    ID_Hello = 1
};
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
    MyFrame *frame = new MyFrame();
    frame->Show(true);
    return true;
}
MyFrame::MyFrame()
    : wxFrame(NULL, wxID_ANY, "Hello World")
{
    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!");
    Bind(wxEVT_MENU, &MyFrame::OnHello, this, ID_Hello);
    Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT);
    Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
}
void MyFrame::OnExit(wxCommandEvent& event)
{
    Close(true);
}
void MyFrame::OnAbout(wxCommandEvent& event)
{
    wxMessageBox("This is a wxWidgets Hello World example",
                 "About Hello World", wxOK | wxICON_INFORMATION);
}
void MyFrame::OnHello(wxCommandEvent& event)
{
    wxLogMessage("Hello world from wxWidgets!");
}
They say that you need to fake something in CMakeLists.txt , but it seems that under Ubuntu it's not clear :).
Help me please :))!
ISSUE IS RESOLVED!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Stolyarov, 2018-07-14
@Ni55aN

We need target_include_directories to the directory with wxWidgets, from where the header files are taken during the build. In the meantime, the build utility does not know where to get the specified header file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question