Hi, in my daily work, I used the wx libraries installed by the pacman command under msys2 gcc environment. But our wxWidgets project wizard does not support creating a project for those libraries. I have just modify the wizard.script, and here is the patch file:
diff --git a/wizard.script b/wizard.script
index 679e184..233d284 100644
--- a/wizard.script
+++ b/wizard.script
@@ -51,6 +51,8 @@ GuiAppType <- 1; // Default to Dialog. 0-Dialog, 1-Frame
AddlLibList <- _T(""); // Contains the complete list
multi_thread_dynamic <- true; //Default to Multi-thread. For MSVC only.
+IsMsys2Lib <- true; // when we are using the header files and libraries from Msys2 installed by pacman
+
function BeginWizard()
{
@@ -75,17 +77,20 @@ function BeginWizard()
Wizard.AddProjectPathPage();
Wizard.AddPage(_T("WxProjDetails"));
Wizard.AddPage(_T("WxGuiSelect"));
- if (PLATFORM == PLATFORM_MSW)
+
+
+ // if we are working under the msys2 environment, the header files and lib files are similar to the Unix type
+ if (PLATFORM == PLATFORM_MSW && !IsMsys2Lib)
Wizard.AddGenericSelectPathPage(_T("WxPath"), wxpath_msg, _("wxWidgets' location:"), _T("$(#wx)"));
// we need the compiler selection before wx settings, because we 'll have
// to validate the settings. To do this we must know the compiler beforehand...
Wizard.AddCompilerPage(_T(""), _T("*"), true, true);
- if (PLATFORM == PLATFORM_MSW)
+ if (PLATFORM == PLATFORM_MSW && !IsMsys2Lib)
Wizard.AddPage(_T("WxConf")); // only for windows
else
Wizard.AddPage(_T("WxConfUnix")); // just PCH option
- if (PLATFORM == PLATFORM_MSW)
+ if (PLATFORM == PLATFORM_MSW && !IsMsys2Lib)
{
Wizard.AddPage(_T("WxConfAdvOpt")); // Wizard page to select target type
Wizard.AddPage(_T("WxAddLib")); // Add additional wx libraries
@@ -103,17 +108,17 @@ function BeginWizard()
_("Please select the wxWidgets version you want to use."),
_T("wxWidgets 3.0;wxWidgets 3.1;wxWidgets 3.2;wxWidgets 3.3"),
WxVersion); // select wxwidgets version
- if (PLATFORM == PLATFORM_MSW)
+ if (PLATFORM == PLATFORM_MSW && !IsMsys2Lib)
Wizard.AddGenericSelectPathPage(_T("WxPath"), wxpath_msg, _("wxWidgets' location:"), _T("$(#wx)"));
// we need the compiler selection before wx settings, because we 'll have
// to validate the settings. To do this we must know the compiler beforehand...
Wizard.AddBuildTargetPage(_T(""), false, true, _T(""), _T("*"), true);
- if (PLATFORM == PLATFORM_MSW)
+ if (PLATFORM == PLATFORM_MSW && !IsMsys2Lib)
Wizard.AddPage(_T("WxConf")); // only for windows
else
Wizard.AddPage(_T("WxConfUnix")); // just PCH option
- if (PLATFORM == PLATFORM_MSW)
+ if (PLATFORM == PLATFORM_MSW && !IsMsys2Lib)
{
Wizard.AddPage(_T("WxConfAdvOpt")); // Wizard page to select target type
Wizard.AddPage(_T("WxAddLib")); // Add additional wx libraries
@@ -605,12 +610,26 @@ function SetupProject(project)
local libdir;
SetupAddlLibs();
// set project options
- if (PLATFORM != PLATFORM_MSW)
+ if (PLATFORM != PLATFORM_MSW || IsMsys2Lib)
{
if (ChoiceWxUnixLib == 0)
{
- project.AddCompilerOption(_T("`wx-config --cflags`"));
- project.AddLinkerOption(_T("`wx-config --libs`"));
+ if (IsMsys2Lib)
+ {
+ // WX_CONFIG is a Code::Blocks global variable which can be set under
+ // MENU->Settings->Global Variable Editor, e.g. it could be:
+ // wx-config-msys2.exe --prefix=$(TARGET_COMPILER_DIR)
+ // in the above setting, you should supply wx-config-msys2.exe which can be built from
+ // https://github.com/eranif/wx-config-msys2
+ project.AddCompilerOption(_T("`$(#WX_CONFIG) --cflags`"));
+ project.AddLinkerOption(_T("`$(#WX_CONFIG) --libs`"));
+ project.AddResourceCompilerOption(_T("`$(#WX_CONFIG) --rcflags`"));
+ }
+ else
+ {
+ project.AddCompilerOption(_T("`$(#WX_CONFIG) --cflags`"));
+ project.AddLinkerOption(_T("`$(#WX_CONFIG) --libs base,core`"));
+ }
}
else
{
@@ -929,7 +948,7 @@ function SetupTarget(target, is_debug)
LibDebugSuffix = _T("");
/* For Linux / Mac */
- if (PLATFORM != PLATFORM_MSW)
+ if (PLATFORM != PLATFORM_MSW || IsMsys2Lib)
{
if (ChoiceWxUnixLib == 1)
{
The patch is very simple, it first add a new variable named "IsMsys2Lib", and by I set it to "true". The wx library supplied by msys2/gcc is using some kinds of Linux format, so I change some code of the wizard.script to follow the condition of the PLATFORM == Unix branch.
To build the generated project, you have to define your global variable named "wx_config".
In my case, it refer to something like below:
wx-config-msys2.exe --prefix=$(TARGET_COMPILER_DIR)
Note that the "wx-config-msys2.exe" can be built from the github repo:
https://github.com/eranif/wx-config-msys2 (Thanks eranif)
You can define the "wx_config" to other strings, for example:
Re: codeblocks cbp projects for wx samples, in this post, if you would like to use a wx library build you self, you can define the string as:
wx-config.exe --prefix=F:/code/wxWidgets-3.2.1 --wxcfg=gcc_dll/mswu
Note the "wx-config.exe" can also be built from the github repo:
https://github.com/eranif/wx-config-msys2Basically, you have to create a user defined wizard.script file under you C::B's APPDATA folder, usually:
%APPDATA%\CodeBlocks\share\codeblocks\templates\wizard\wxwidgets
If you do not understand where you %APPDATA% locates, you can see this as a reference:
wxpbguide/cb/wizard at master PBfordev/wxpbguide (Thanks PB)
See this thread
New Variable to support wx-config in MSys2 MinGW to understand how the global variable can be defined and used to support building. (Thanks stahta01)
I have attach the wizard file if you are lazy to apply my patch.
If you have any issue, comments are welcome!