wxWidgets and codelite build problem

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

wxWidgets and codelite build problem

Post by Eman »

Hello
I installed minGW on Windows 10 on drive C. Then, I installed codelite. After that I installed wxWidget using windows installer file( the folder is created under C:\wxWidgets-3.1.4)
I setup that environment variables in codelite as:
WXWIN=C:\wxWidgets-3.1.4
WXCFG=gcc_dll\mswud
PATH=$(PATH);C:\MinGW\bin

I want to build a simple app to test the installation:

Code: Select all

#include <wx/wx.h>

// application class
class wxMiniApp : public wxApp
{
public:
	// function called at the application initialization
	virtual bool OnInit();

	// event handler for button click
	void OnClick(wxCommandEvent& event) {
		GetTopWindow()->Close();
	}
};

IMPLEMENT_APP(wxMiniApp);

bool wxMiniApp::OnInit()
{
	// create a new frame and set it as the top most application window
	SetTopWindow( new wxFrame( NULL, -1, wxT(""), wxDefaultPosition, wxSize( 100, 50) ) );

	// create new button and assign it to the main frame
	new wxButton( GetTopWindow(), wxID_EXIT, wxT("Click!") );

	// connect button click event with event handler
	Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxMiniApp::OnClick) );

	// show main frame
	GetTopWindow()->Show();

	// enter the application's main loop
	return true;
}
However, I get these errors:
C:\WINDOWS\system32\cmd.exe /C C:/Min-gw/mingw64/bin/mingw32-make.exe -j8 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ TryWorkspace - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/f-alm/Desktop/Eman/TryWorkspace/TryWorkspace'

Please use the --wxcfg flag (as in wx-config --wxcfg=gcc_dll/mswud)
or set the environment variable WXCFG (as in WXCFG=gcc_dll/mswud)
to specify which configuration exactly you want to use.

Please use the --wxcfg flag (as in wx-config --wxcfg=gcc_dll/mswud)
or set the environment variable WXCFG (as in WXCFG=gcc_dll/mswud)
to specify which configuration exactly you want to use.

Please use the --wxcfg flag (as in wx-config --wxcfg=gcc_dll/mswud)
or set the environment variable WXCFG (as in WXCFG=gcc_dll/mswud)
to specify which configuration exactly you want to use.

Please use the --wxcfg flag (as in wx-config --wxcfg=gcc_dll/mswud)
or set the environment variable WXCFG (as in WXCFG=gcc_dll/mswud)
to specify which configuration exactly you want to use.
C:/Min-gw/mingw64/bin/g++.exe -c "C:/Users/f-alm/Desktop/Eman/TryWorkspace/TryWorkspace/main.cpp" -g -O0 -Wall wx-config Error: No valid setup.h of wxWidgets has been found at location: C:/wxWidgets-3.1.4/lib/gcc_dll\mswud/wx/setup.h -o ../build-Debug/TryWorkspace/main.cpp.o -I.
g++.exe: error: wx-config: No such file or directory
g++.exe: error: Error:: Invalid argument
g++.exe: error: No: No such file or directory
g++.exe: error: valid: No such file or directory
g++.exe: error: setup.h: No such file or directory
g++.exe: error: of: No such file or directory
g++.exe: error: wxWidgets: No such file or directory
g++.exe: error: has: No such file or directory
g++.exe: error: been: No such file or directory
g++.exe: error: found: No such file or directory
g++.exe: error: at: No such file or directory
g++.exe: error: location:: Invalid argument
g++.exe: error: C:/wxWidgets-3.1.4/lib/gcc_dll\mswud/wx/setup.h: No such file or directory
mingw32-make.exe[1]: *** [TryWorkspace.mk:100: ../build-Debug/TryWorkspace/main.cpp.o] Error 1
mingw32-make.exe[1]: *** Waiting for unfinished jobs....
mingw32-make.exe[1]: Leaving directory 'C:/Users/f-alm/Desktop/Eman/TryWorkspace/TryWorkspace'
mingw32-make.exe: *** [Makefile:5: All] Error 2
====0 errors, 0 warnings====

Any help is highly apprecaited
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWidgets and codelite build problem

Post by PB »

For starters, the MinGW install folders do not match?
Eman wrote: Sun Feb 07, 2021 6:00 pm PATH=$(PATH);C:\MinGW\bin
vs
Eman wrote: Sun Feb 07, 2021 6:00 pm C:/Min-gw/mingw64/bin/g++.exe -c "C:/Users/f-alm/Desktop/Eman/TryWorkspace/TryWorkspace/main.cpp" -g -O0 -Wall wx-config Error: No valid
Aditionally, the installer installs only the source code and one has to build the libraries. Looking at the wx-config error, it seems you did not build the libraries, did you?

BTW, the example code you wrote is rather odd. I recommend taking a look at the bundled samples or the Hello World in the documentation to see how the code using wxWidgets should look.
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

Thank you
No, I have not built the libraries. I thought this will be done by the installer. Also, there are many sources for "how to build" could you please recommend me one that has good expalnation?

I have just tried hello world example, it gave the same errors.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets and codelite build problem

Post by ONEEYEMAN »

Hi,
1. The installer just installs the source code. It doesn't know what compiler you want to use to build the library, not what configuration you need. So you will need to do it yourself.
2. The simplest way to build the library is to do:

Code: Select all

cd c:\wxWidgets\build\msw
mingw32-exe -f makefile.gcc BUILD=debug
Adjust directory name and the compiler name as appropriate

Then since you are on Windows, create a new project from scratch and see if you can build it.
If not - add all include directories and appropriate libraries to the project. If you have problems adding them - let us know.

Thank you.
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

Thanks a lot. This is my adjustment, so in cmd:
cd C:\wxWidgets-3.1.4\build\msw
mingw32-exe -f makefile.gcc BUILD=debug

I got:
'mingw32-exe' is not recognized as an internal or external command,
operable program or batch file.

To Check the installed compiler:
cd C:\Min-gw\mingw64\bin
mingw32-make --version
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Last edited by Eman on Sun Feb 07, 2021 7:42 pm, edited 1 time in total.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWidgets and codelite build problem

Post by PB »

Firstly, you need to decide whether you need to build wxWidgets by yourself, or use the pre-built binaries.

Secondly, the official documentation for buiding wxWidgets on MSW is here:
https://docs.wxwidgets.org/trunk/page_p ... port_wxmsw

Thirdly, if you build wxWidgets by yourself, you need to decide whether to use shared (DLL) or static build. You should also build both Debug and Release configurations.

Lastly, if you want to use a compiler toolchain, you need to add it to PATH before using it.

FWIW, I have written information about installing and building wxWidgets with MinGW in chapters 2 and 3 of my guide, although it now uses a different mingw-64 distribution. However, all that is really different are the install paths...
You can also see examples of bat files used for building wxWidgets here but I am not sure if they are useful without reading the guide which describes them.
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

I built wxWidget.
This is myApp

Code: Select all

// 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(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);
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!");
}
After building this app in codeLite. This is the build log:

Code: Select all


C:\WINDOWS\system32\cmd.exe /C C:/Min-gw/mingw64/bin/mingw32-make.exe -j8 SHELL=cmd.exe -e -f  Makefile

"----------Building project:[ TryWorkspace - Debug ]----------"

mingw32-make.exe[1]: Entering directory 'C:/Users/f-alm/Desktop/Eman/TryWorkspace/TryWorkspace'

C:/Min-gw/mingw64/bin/g++.exe -o ..\build-Debug\bin\TryWorkspace @../build-Debug/TryWorkspace/ObjectsList.txt -L.   -mwindows  -mthreads -LC:/wxWidgets-3.1.4/lib/gcc_dll -lwxmsw31ud_richtext -lwxmsw31ud_xrc -lwxmsw31ud_aui -lwxmsw31ud_html -lwxmsw31ud_adv -lwxmsw31ud_core -lwxbase31ud_xml -lwxbase31ud_net -lwxbase31ud -lwxscintillad -lwxtiffd -lwxjpegd -lwxpngd -lwxzlibd -lwxregexud -lwxexpatd -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwxregexud -lwinspool -lwinmm -lshell32 -lcomctl32 -lversion -lshlwapi -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -luxtheme -loleacc

mingw32-make.exe[1]: Leaving directory 'C:/Users/f-alm/Desktop/Eman/TryWorkspace/TryWorkspace'

====0 errors, 0 warnings====
However, there is red arrow next to the line==> #include <wx/wx.h>

Running the app, no window appears, it flashes for very short time.
Is everything OK?
Last edited by Eman on Sun Feb 07, 2021 9:48 pm, edited 1 time in total.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWidgets and codelite build problem

Post by PB »

My guess is, the application does not start because it is missing DLLs. Either wxWidgets', compiler's, or both. Run it from the File Explorer and it will tell you.

BTW, you should not define a control ID with a value of 1, user-defined IDs must be outside the wxID_LOWEST - wxID_HIGHEST range to not clash with wxWidgets ones.

EDIT:
Sorry, according to the official documentation, ID of 1 is actually allowed. However, I still have some memories of some issues with it...
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

The example is from the official website, I will try.
How to run from explorer?
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

The output log says:

Working directory is set to: C:\Users\f-alm\Desktop\Eman\TryWorkspace\build-Debug\lib
Executing: cmd /C call C:\Users\f-alm\Desktop\Eman\TryWorkspace\build-Debug\bin\TryWorkspace.exe && pause
Program exited
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWidgets and codelite build problem

Post by PB »

Did you try to launch the executable of your application from File Explorer, not command line?

As I wrote before, and assuming your program just does not silently crash, I believe that you are missing the DLLs. File Explorer will tell you which ones. You should copy them to the same directory your .exe file is.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets and codelite build problem

Post by ONEEYEMAN »

Hi,
What exact command you used to build wxWidgets?

Thank you
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

I am not running from command line. but, from codelite itself, Build menu ==> choose run
I do not know how to run form Explorer?
Also, in my project workspace, i found this file:
wxMSW-3.1.4-Setup
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

ONEEYEMAN wrote: Sun Feb 07, 2021 10:25 pm Hi,
What exact command you used to build wxWidgets?

Thank you
cd C:\wxWidget-3.1.4\build\msw
mingw32-make -f makefile.gcc SHARED=1 BUILD=debug
mingw32-make -f makefile.gcc SHARED=1 BUILD=release
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

While there is 0 errors and warnings
There is red arrow beside #include <wx/wx.h>
when i hover next to it a message apperas:
in included file: definition of builtin function '__rdtsc' C:\Min-gw\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\ia32intrin.h:112:1:note: error occurred here
Post Reply