News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

[Solved] Code::Blocks and makefile: unexpected behaviour

Started by simac, June 03, 2017, 12:40:38 PM

Previous topic - Next topic

simac

Hello everybody !
I'm trying to compile a wxWidgets Windows app with MinGW. To do this I'm using the makefile.gcc provided with the minimal sample.
When I compile the minimal example with mingw32-make -f makefile.gcc BUILD=release SHARED=1 UNICODE=1 all work perfectly. However if I use Code::Blocks and configure the project to use the makefile (Build project/target: $make -f $makefile BUILD=release SHARED=1 UNICODE=1 ) the compilation work properly, but the program crashes when starting.
Moreover the objects files and the executables are different between the two ways. I can't find out a reason why.
Could you help me?

Thank you in advance,
Simac
If I made some English mistakes, please notice me: I'm not an English native speaker.

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

simac

#2
That's a part of the problem: nothing differs. The build log is exactly the same with CB and the makefile:

With the makefile:windres --use-temp-file -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 --include-dir ./../../samples --define NOPCH
g++ -c -o gcc_mswudll\minimal_minimal.o  -O2 -mthreads  -DHAVE_W32API_H -D__WXMSW__   -DNDEBUG    -D_UNICODE  -I.\..\..\lib\gcc_dll\mswu -I.\..\..\include  -W -Wall -I. -DWXUSINGDLL -I.\..\..\samples -DNOPCH   -Wno-ctor-dtor-privacy   -s -MTgcc_mswudll\minimal_minimal.o -MFgcc_mswudll\minimal_minimal.o.d -MD -MP minimal.cpp
g++ -o gcc_mswudll\minimal.exe gcc_mswudll\minimal_sample_rc.o gcc_mswudll\minimal_minimal.o   -mthreads -L.\..\..\lib\gcc_dll -Wl,--subsystem,windows -mwindows    -lwxmsw30u_core  -lwxbase30u    -lwxtiff -lwxjpeg -lwxpng   -lwxzlib -lwxregexu -lwxexpat    -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lwininet -s


With CB:
Code (html5) Select
<html>
<head>
<title>minimal build log</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<tt>
Build started on: <u>03-06-2017 at 17:11.03</u><br />
Build ended on: <u>03-06-2017 at 17:11.07</u><p />
<b>-------------- Build: release in minimal (compiler: GNU GCC Compiler)---------------</b><br />
mingw32-make.exe -f makefile.gcc BUILD=release SHARED=1 UNICODE=1 <br />
windres --use-temp-file -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 --include-dir ./../../samples --define NOPCH<br />
g++ -c -o gcc_mswudll\minimal_minimal.o  -O2 -mthreads  -DHAVE_W32API_H -D__WXMSW__   -DNDEBUG    -D_UNICODE  -I.\..\..\lib\gcc_dll\mswu -I.\..\..\include  -W -Wall -I. -DWXUSINGDLL -I.\..\..\samples -DNOPCH   -Wno-ctor-dtor-privacy   -s -MTgcc_mswudll\minimal_minimal.o -MFgcc_mswudll\minimal_minimal.o.d -MD -MP minimal.cpp<br />
g++ -o gcc_mswudll\minimal.exe gcc_mswudll\minimal_sample_rc.o gcc_mswudll\minimal_minimal.o   -mthreads -L.\..\..\lib\gcc_dll -Wl,--subsystem,windows -mwindows    -lwxmsw30u_core  -lwxbase30u    -lwxtiff -lwxjpeg -lwxpng   -lwxzlib -lwxregexu -lwxexpat    -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lwininet -s<br />
<font color="#0000ff">Process terminated with status 0 (0 minute(s), 4 second(s))</font><br />
<font color="#0000ff">0 error(s), 0 warning(s) (0 minute(s), 4 second(s))</font><br />
</tt>
</body>
</html>


It is very strange !
If I made some English mistakes, please notice me: I'm not an English native speaker.

stahta01

Since you posted an HTML file; I really did NOT look for differences.

But, if there is no difference the first thing to check is that you are using the exact same GCC Compiler/toolchain.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

simac

I checked the version of the compiler and it's the same with CB and the command line. I tried with a nighty-build version of CB and I've still got the problem.
If I made some English mistakes, please notice me: I'm not an English native speaker.

stahta01

#5
Quote from: simac on June 03, 2017, 10:10:24 PM
I checked the version of the compiler and it's the same with CB and the command line. I tried with a nighty-build version of CB and I've still got the problem.

Is it the exact same Compiler?

Edit: The command below in the cmd.exe prompt used to build wxWidgets should show the path of the gcc used; compare with the CB Toolchain setting.

where gcc

or

where gcc.exe


Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

simac

I didn't know this command! Very useful!

You're right, the gcc used in the cmd wasn't the same as the one used by CB... I didn't even know that I had another gcc on my computer...
I removed the unexpected location from the PATH, and all seems to work perfectly.

I would like so much banging my head against the wall, but I'm afraid I would damage the wall!

Thank you very much!

Simac
If I made some English mistakes, please notice me: I'm not an English native speaker.