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.
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,
OK, that helped.
What you need to do is open the Windows Explorer, go to the place where you project is, you open another instance of the Windows Explorer and find the file named <your_project_name>.exe and you navigate to the c:\wxWidgets-3.1.4\gcc_dll\mswud.
Copy the file named wxbase*.dll and wxmswcore*.dll to the place where the executable is in the other Explorer and re-run it.

If you don't want to do this, run the following:

Code: Select all

cd c:\wxWidgets-3.1.4\build\msw
mingw32-make -f makefile.gcc SHARED=0 BUILD=debug
mingw32-make -f makefile.gcc SHARED=0 BUILD=release
then recreate the project, rebuild and it will run.

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 »

Many thanks for your help.
I run the build commands again with SHARED=0
I set Environment variables in codelite:
CodeLiteDir=C:\Program Files\CodeLite
WXWIN=C:\wxWidgets-3.1.4
WXCFG=gcc_dll/mswud

Also, I used the automatic code generated by codelite:
main.cpp

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;
}
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:[ abc - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/f-alm/Desktop/Eman/abc/abc'

C:/Min-gw/mingw64/bin/g++.exe  -c  "C:/Users/f-alm/Desktop/Eman/abc/abc/main.cpp" -g -O0 -Wall -mthreads -DHAVE_W32API_H -D__WXMSW__ -D__WXDEBUG__ -D_UNICODE -IC:/wxWidgets-3.1.4/lib/gcc_dll/mswud -IC:/wxWidgets-3.1.4/include -DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0     -o ../build-Debug/abc/main.cpp.o -I.

C:/Min-gw/mingw64/bin/g++.exe -o ..\build-Debug\bin\abc @../build-Debug/abc/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/abc/abc'
====0 errors, 0 warnings====
For the run, a window appear and disapper quickly and i could not noticed any thing
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 also tried the pre-built lib
I went to : https://www.wxwidgets.org/downloads/
I Downloaded windows binaries: for MinGW-w64 8.1 (Header Files+ Development Files+Release DLLs) for 64-bit
Then, under C, I created:
C:\wxWidgets\3.1.4
I unzipped the headers, and get include folder inside C:\wxWidgets\3.1.4
I unzipped the Development, and get lib folder C:\wxWidgets\3.1.4
(I renamed the folder inside lib, the new name is gcc_dll )
I did not unzip the release DLLs since it gives lib folder also, so I do not know what to do
In codelite settings  environment variables, I set:
WXWIN=C:\wxWidgets\3.1.4
WXCFG=gcc_dll\mswud

The build log is :

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:[ abc - Debug ]----------"

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

C:/Min-gw/mingw64/bin/g++.exe -o ..\build-Debug\bin\abc @../build-Debug/abc/ObjectsList.txt -L.   -mwindows wx-config Error: Unable to open file 'C:/wxWidgets/3.1.4/build/msw/config.gcc'.  -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
g++.exe: error: wx-config: No such file or directory
g++.exe: error: Error:: Invalid argument
g++.exe: error: Unable: No such file or directory
g++.exe: error: to: No such file or directory
g++.exe: error: open: No such file or directory
g++.exe: error: file: No such file or directory
g++.exe: error: C:/wxWidgets/3.1.4/build/msw/config.gcc.: No such file or directory
mingw32-make.exe[1]: *** [abc.mk:83: ..\build-Debug\bin\abc] Error 1
mingw32-make.exe: *** [Makefile:5: All] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/f-alm/Desktop/Eman/abc/abc'
====0 errors, 0 warnings====
i am trying to solve the error:
Error: Unable to open file 'C:/wxWidgets/3.1.4/build/msw/config.gcc'
becuase there is no build folder under 3.1.4
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 the third time: I think you were fine before, you just needed to make the required DLLs available to your application. Do you have anything which contradicts this?

I would not go down to the rabbit hole which is using prebuilt binaries with CodeLite, see the thread next to yours in this forum section.

Please do not tell me that you do not know of File Explorer (formerly known as Windows Explorer), which has been the default file manager on Microsoft Windows for decades.
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

PB wrote: Mon Feb 08, 2021 6:28 am For the third time: I think you were fine before, you just needed to make the required DLLs available to your application. Do you have anything which contradicts this?

I would not go down to the rabbit hole which is using prebuilt binaries with CodeLite, see the thread next to yours in this forum section.

Please do not tell me that you do not know of File Explorer (formerly known as Windows Explorer), which has been the default file manager on Microsoft Windows for decades.
I have not used Windows for 10 years. I am a returned user. I knew Window Explorer.

I returned to the wXwidget-3.1.4 that I built my self.
I edited the setting of codelite project settings:
under compiler settings --> Additional Include Paths --> C:\wxWidgets-3.1.4\include
under linker settings --> Libraries Search Path --> C:\wxWidgets-3.1.4\lib

This is 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:[ abc - Debug ]----------"

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

C:/Min-gw/mingw64/bin/g++.exe -o ..\build-Debug\bin\abc @../build-Debug/abc/ObjectsList.txt -L. -LC:\wxWidgets-3.1.4\lib   -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/abc/abc'
====0 errors, 0 warnings====
Run --> the window disappear
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 7:02 pm 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.
Yes, please, my problem is adding "include directories and appropriate libraries to the project"
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, CodeLite uses for wxWidgets projects wx-config, which, assuming you are using default setting with self-built wxWidgets, should work out of the box and add the correct include and library paths as well as the libraries themselves. I would just create a wxWidgets project with CodeLite, leaving everything at its defaults.

Secondly, I am surprised that the build succeeded without errors, as wxWidgets requires adding two include directories:
1. The build-specific one, e.g. WXWIN/lib/gcc_dll/mswud for the dynamic shared build.
2. The build-agnostic one: WXWIN/include.

Last but not least: What happens when you use File Explorer to navigate to your executable (you should be able to find it based on the directories listed in the build log) and try to launch 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 »

Thanks for your help.
I run abc.exe
This is the error:
The code execution cannot proceed because wxmsw314ud_core_gcc_custom.dll was not found. Reinstalling the program may fix this problem.

this image shows the error:
https://www.mediafire.com/view/qn9132kk ... .jfif/file

However, wxmsw314ud_core_gcc_custom.dll
is in my
C:\wxWidgets-3.1.4\lib\gcc_dll

My codelite's environments variables:
CodeLiteDir=C:\Program Files\CodeLite
WXWIN=C:\wxWidgets-3.1.4
WXCFG=gcc_dll/mswud

Also, the codelite version is 15.0.0, wxWidget is 3.1.4, do I need to install earlier version of codelite to solve the problem?
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

PB wrote: Sun Feb 07, 2021 10:21 pm 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.
I will try your solution, but do I need to do that for every project I will create in codelite, I mean, each time I need to "copy them to the same directory your .exe file" ?
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 »

All the DLLs an application needs (e.g., wxWidgets from WXWIN/lib/gcc_dll folder, compiler's from the mingw bin folder) must be somewhere where the application can find them. For non-system libraries, this is usually done by copying them to the folder where the executable is. This has nothing to do with wxWidgets or CodeLite, that is how Microsoft Windows works.

If you find this annoying, you can add the folders with libraries to your PATH. However, I would not recommend it, as it can lead to issues when multiple DLLs or programs with the same name are available in PATH.

One can also build wxWidgets and application statically, so that no DLLs at all are needed.

FWIW, Code::Blocks automatically adds the needed paths for libraries and compiler DLLs, so one can run a program from within IDE with no problems.It seems that CodeLite does not have this.
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

Many Thanks. I have edited the codelite's Environment Variables:

CodeLiteDir=C:\Program Files\CodeLite
PATH=C:\wxWidgets-3.1.4\lib\gcc_dll;$(PATH)
WXWIN=C:\wxWidgets-3.1.4
WXCFG=gcc_dll/mswud


The run works now! But, is editing codelite's Environment Variable PATH not recommended? or you mean the PATH in Windows settings?

Regarding your suggestion, " build wxWidgets and application statically, so that no DLLs at all are needed." Do you mean static build as follows :
mingw32-make -f makefile.gcc SHARED=0 BUILD=debug
mingw32-make -f makefile.gcc SHARED=0 BUILD=release
because I first run the above commands with SHARED=1 (dynamic) then with SHARED=0 (static), so I did both, but I needed DLLs
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,
Yes, that is exactly what PB meant.
However, the DLL build of wxWidgets means that you will be developing DLL yourself on top of the main application. Is that so?

Otherwise using dynamic build of wxWidgets have no sense.

Thank you.
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Re: wxWidgets and codelite build problem

Post by eranif »

The better solution is to add this to the project environment variables or to the workspace environment variables:

right click on the workspace icon -> environment variables (this will affect all projects in the workspace)
OR:
or right click on the project -> settings -> environment page (this will affect only this particular project)
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
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: Mon Feb 08, 2021 7:33 pm Hi,
Yes, that is exactly what PB meant.
However, the DLL build of wxWidgets means that you will be developing DLL yourself on top of the main application. Is that so?

Otherwise using dynamic build of wxWidgets have no sense.

Thank you.
Many thanks for you all.
I am developing c++ project (simple robotic simulator) using GUI (wxWidgets). I am not sure which was better for me dynamic or static build?
Eman
Experienced Solver
Experienced Solver
Posts: 68
Joined: Sat Aug 31, 2019 2:11 pm

Re: wxWidgets and codelite build problem

Post by Eman »

eranif wrote: Mon Feb 08, 2021 7:35 pm The better solution is to add this to the project environment variables or to the workspace environment variables:

right click on the workspace icon -> environment variables (this will affect all projects in the workspace)
OR:
or right click on the project -> settings -> environment page (this will affect only this particular project)
Thank you. Do you mean adding PATH=C:\wxWidgets-3.1.4\lib\gcc_dll without $(PATH) ?
Post Reply