Hi, thanks for the time and help.
I would like to find a simple way, here is my try steps:
I try to create a cbp file which use the makefile.gcc under the sample/minimal folder.
I add the line
makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 VENDOR=cb
Because I built wx library with the command:
mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 VENDOR=cb
Now, I have a "all" build target of the cbp file.
When I click the "build" button, I got this:
-------------- Build: all in minimal (compiler: GNU GCC Compiler)---------------
[100.0%] Checking if target is up-to-date: mingw32-make.exe -q -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 VENDOR=cb all
Running command: mingw32-make.exe -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 VENDOR=cb all
process_begin: CreateProcess(NULL, F:/msys2/mingw64/bin/ -c "if not exist gcc_mswudll mkdir gcc_mswudll", ...) failed.
make (e=5): 拒绝访问。
mingw32-make: [makefile.gcc:206: gcc_mswudll] Error 5 (ignored)
if not exist gcc_mswudll mkdir gcc_mswudll
windres -i../../samples/sample.rc -ogcc_mswudll\minimal_sample_rc.o --define __WXMSW__ --define NDEBUG --define _UNICODE --include-dir .\..\..\lib\gcc_dll\mswu --include-dir ./../../include --include-dir . --define WXUSINGDLL --define wxUSE_DPI_AWARE_MANIFEST=2 --include-dir ./../../samples --define NOPCH
windres: gcc_mswudll\minimal_sample_rc.o: No such file or directory
mingw32-make: *** [makefile.gcc:224: gcc_mswudll\minimal_sample_rc.o] Error 1
Process terminated with status 2 (0 minute(s), 0 second(s))
3 error(s), 0 warning(s) (0 minute(s), 0 second(s))
The Chinese text means "access deny".
When I look at the makefile.gcc, I see this line:
$(OBJS):
-if not exist $(OBJS) mkdir $(OBJS)
This means the makefile does not work correctly under C::B, while I see it works correctly under Windows cmd.
Here is the log under Windows CMD
F:\code\wxWidgets-3.2.1\samples\minimal>mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 VENDOR=cb all
if not exist gcc_mswudll mkdir gcc_mswudll
windres -i../../samples/sample.rc -ogcc_mswudll\minimal_sample_rc.o --define __WXMSW__ --define NDEBUG --define _UNICODE --include-dir .\..\..\lib\gcc_dll\mswu --include-di
r ./../../include --include-dir . --define WXUSINGDLL --define wxUSE_DPI_AWARE_MANIFEST=2 --include-dir ./../../samples --define NOPCH
g++ -c -o gcc_mswudll\minimal_minimal.o -O2 -mthreads -D__WXMSW__ -DNDEBUG -D_UNICODE -I.\..\..\lib\gcc_dll\mswu -I.\..\..\include -W -Wall -I. -DWXUSINGDLL -I.\..\..\sample
s -DNOPCH -Wno-ctor-dtor-privacy -MTgcc_mswudll\minimal_minimal.o -MFgcc_mswudll\minimal_minimal.o.d -MD -MP minimal.cpp
g++ -o gcc_mswudll\minimal.exe @gcc_mswudll\minimal.exe.rsp -mthreads -L.\..\..\lib\gcc_dll -Wl,--subsystem,windows -mwindows -lwxmsw32u -lwxscintilla -lwxtiff -lwxjpeg -
lwxpng -lwxzlib -lwxregexu -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lve
rsion -lws2_32 -lwininet -loleacc -luxtheme
So, it looks like a wrong shell is called? or any solutions?
Thanks.
EDIT: problem solved!
The problem is that I have a path:
$(TARGET_COMPILER_DIR)../usr/bin
In the compiler's extra path. I just remove this line, and restart C::B, and it is OK now.
EDIT2:
I think this issue has already mentioned by AndrewCot (https://forums.codeblocks.org/index.php?action=profile;u=49543), because I have put the msys' shell path usr/bin to the mingw64/bin path. Though I can use the sh.exe to call the wx-config script, but this also cause this issue.
I have created some MSYS2 specific project files that use the wx-config and found it's not easy in that like you found out if you forget to remove the additional path it causes problems.
I did not think of eranif's wx-config-msys2.exe. If it works then it would remove the need for the additional path and would probably the best solution if it works. I should try it with the MSYS2 C::B project files I created for some testing I did.
eranif's wx-config-msys2.exe works correctly. I use it for some of my personal wx based projects.
What you need to do is adding something like:
`wx-config-msys2 --libs all --prefix=$(TARGET_COMPILER_DIR)`
or
`wx-config-msys2 --cflags --prefix=$(TARGET_COMPILER_DIR)`
In the compiler or linker options.
I have created a bunch of project files for plugins that do not have any for Linux. I pick an existing one and remove the file list and save it as a "template" and then copy it into the directory I want it in. I add the files and update it via Notepad++ as it is quicker than using C::B. Once I have it done I then open it in C::B and fix the build issues due to missing stuff or changes for the new directory, which I then feed into the template for the next project.
Yes, this is a workaround. I also did the similar things, especially I would like to test some wx sample code. I'm not satisfied with this method. Especially for wx and C::B beginner.
I have been playing with wx-config-msys2 source and have got it sort of working in building C::B. I have created a C::B project for it and added it to my msys C::B workspace.
I need to first build the wx-config-msys.exe before I can then use it via a global variable. Once wx-config-msys.exe exists I then need to reload the workspace before I can then build C::B.
I need to look at the backticks expansion and see where the project file backtick expansion occurs as the expansion needs to occur at project compile time rather than at project load time. My guess is that currently the expansion occurs when the project is loaded loaded and as the wx-config-msys.exe file does not exist then the expansion does not work or is an empty string. I need to investigate this as it is not currently working properly IMHO.
This is an example of my usage and variable setup:
Example project settings: <Compiler>
<Add option="`$(#WXWIDGETS.WX_CONFIG) --cflags`" />
</Compiler>
<Linker>
<Add option="`$(#WXWIDGETS.WX_CONFIG) --libs std,aui,propgrid`" />
</Linker>
#WXWIDGETS.WX_CONFIG setting:
D:\Andrew_Development\Work_Installers\CodeBLocks_Private_Experimental_GCC\src\devel32_64\wx-config-msys2.exe --prefix=$(TARGET_COMPILER_DIR)
EDIT
I found an old reop which is also by tim
stahta01/cb_projects_for_wxWidgets: Code::Blocks projects for building wxWidgets sample code (https://github.com/stahta01/cb_projects_for_wxWidgets)
It was several years ago, and it use the wx-config.exe.
I think tim's this repo could be a start work base.
I see in each cbp file of this repo, it has something like:
<Target title="win_gcc">
<Option output="bin/$(TARGET_NAME)/$(PROJECT_NAME)" prefix_auto="1" extension_auto="1" />
<Option object_output=".objs/$(TARGET_NAME)" />
<Option type="0" />
<Option compiler="gcc" />
<Option projectLinkerOptionsRelation="2" />
<Compiler>
<Add option="`$(WX_CONFIG) --cflags`" />
</Compiler>
<Linker>
<Add option="`$(WX_CONFIG) --libs std,ribbon`" />
</Linker>
<Environment>
<Variable name="WX_CONFIG" value="wx-config --compiler=gcc --wxcfg=$(WXCFG)" />
</Environment>
</Target>
Here, tim use the "WX_CONFIG" variable. This variable is cbp dependent, I think a better method is using the C::B's global compiler variable, such as #WXWIDGETS.WX_CONFIG
So, basically, what I need to do is:
1, remove the <Environment> section.
2, change the $(WX_CONFIG) to #WXWIDGETS.WX_CONFIG
3, add a gcv, which point the #WXWIDGETS.WX_CONFIG to the correct wx-config-msys2.exe or wx-config.exe
4, update tim's repo code in samples to the latest wx 3.2.1
Here are some news:
I have a fork from Tim's repo, and I have used the gcv(global compiler variable) WX_CONFIG
Some of samples are updated and worked fine by using the wx-config-msys2.exe and the 3.2.0 library inside the msys2 mingw64 toolchain.
Here is the commit history:
Commits asmwarrior/cb_projects_for_wxWidgets (https://github.com/asmwarrior/cb_projects_for_wxWidgets/commits/master)
I'm not sure there is a find/replace method to do all the jobs, currently, I just manually edit the cbp file from C::B the build option dialog.
Some extra issue: when I try to start the generated application exe file, it looks like the starting directory is not correct. (a messagebox will be shown).
EDIT:
My WX_CONFIG setting is:
wx-config-msys2.exe --prefix=$(TARGET_COMPILER_DIR)
What is the messagebox that is shown?
See the screen shot as attachment.
I guess the executing working dir is wrong.
About this issue, currently, there are two folders setting, for example, the caret.cbp file has such content:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="caret" />
<Option execution_dir="../minimal" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="win_gcc">
<Option output="bin/$(TARGET_NAME)/$(PROJECT_NAME)" prefix_auto="1" extension_auto="1" />
<Option working_dir="../../caret" />
<Option object_output=".objs/$(TARGET_NAME)" />
<Option type="0" />
<Option compiler="gcc" />
<Option projectLinkerOptionsRelation="2" />
<Compiler>
<Add option="-O2" />
<Add option="`$(#WX_CONFIG) --cflags`" />
</Compiler>
<Linker>
<Add option="-s" />
<Add option="`$(#WX_CONFIG) --libs base,core,adv`" />
</Linker>
</Target>
</Build>
<VirtualTargets>
<Add alias="All" targets="win_gcc;" />
</VirtualTargets>
<Unit filename="caret.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>
What do you think about the correct value of "execution_dir" and "working_dir"?
The current dir where the cbp file locates? So, the value could be "../caret"? or just "./" ?
EDIT
I choose the later one, I just use the notepad++'s search/replace feature
search this(with regex enabled)
and replace by this:
I have pushed my changes to my repo.
Some good news:
The cbp projects also works under the self build wx library.
For example, you local build wx library is in F:/code/wxWidgets-3.2.1, and you build command could be:
mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 VENDOR=cb
You need the "wx-config.exe" from https://github.com/eranif/wx-config-msys2
What I need to do is:
Open the C::B's Menu->Settings->Global variables
Change the wx_config's base value to something like:
wx-config.exe --prefix=F:/code/wxWidgets-3.2.1 --wxcfg=gcc_dll/mswu
Then, you can build those samples linking to you local build wx.