Author Topic: [Solved] Code::Blocks and makefile: unexpected behaviour  (Read 3868 times)

Offline simac

  • Single posting newcomer
  • *
  • Posts: 5
[Solved] Code::Blocks and makefile: unexpected behaviour
« on: June 03, 2017, 12:40:38 pm »
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
Code
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:
Code
$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
« Last Edit: June 04, 2017, 07:46:39 pm by simac »
If I made some English mistakes, please notice me: I'm not an English native speaker.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline simac

  • Single posting newcomer
  • *
  • Posts: 5
Re: Code::Blocks and makefile: unexpected behaviour
« Reply #2 on: June 03, 2017, 05:18:19 pm »
That's a part of the problem: nothing differs. The build log is exactly the same with CB and the makefile:

With the makefile:
Code
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
<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 !
« Last Edit: June 03, 2017, 05:54:17 pm by simac »
If I made some English mistakes, please notice me: I'm not an English native speaker.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Code::Blocks and makefile: unexpected behaviour
« Reply #3 on: June 03, 2017, 09:24:44 pm »
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++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline simac

  • Single posting newcomer
  • *
  • Posts: 5
Re: Code::Blocks and makefile: unexpected behaviour
« Reply #4 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.
If I made some English mistakes, please notice me: I'm not an English native speaker.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Code::Blocks and makefile: unexpected behaviour
« Reply #5 on: June 03, 2017, 10:15:55 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.
Code
where gcc
or
Code
where gcc.exe

Tim S.
« Last Edit: June 03, 2017, 10:40:57 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline simac

  • Single posting newcomer
  • *
  • Posts: 5
Re: Code::Blocks and makefile: unexpected behaviour
« Reply #6 on: June 04, 2017, 07:44:40 pm »
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.