August 15, 2020, 02:58:19 PM

Author Topic: Can you use a later build of MinGW64 compiler for Blitzmax NG?  (Read 6953 times)

Offline xlsior

  • Jr. Member
  • **
  • Posts: 33
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #15 on: July 30, 2017, 05:17:51 AM »
Seems to be able to compile almost everything with 7.10, except bah.freeimage it appears:

Code: [Select]
[ 13%] Compiling:Flip.cpp
[ 14%] Compiling:JPEGTransform.cpp
[ 14%] Compiling:MultigridPoissonSolver.cpp
[ 14%] Compiling:Rescale.cpp
In file included from c:/code/blitzmaxNG710/mod/bah.mod/freeimage.mod/src/LibTIFF4/tiffio.h:258:0,
                 from c:/code/blitzmaxNG710/mod/bah.mod/freeimage.mod/src/LibTIFF4/tiffiop.h:60,
                 from c:/code/blitzmaxNG710/mod/bah.mod/freeimage.mod/src/FreeImage/PluginG3.cpp:23:
c:/code/blitzmaxNG710/MinGW32x86/i686-w64-mingw32/include/stdio.h:541:23: error: conflicting declaration of 'int _snprintf(char*, size_t, const char*, ...)' with 'C' linkage
   _CRTIMP int __cdecl _snprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
                       ^~~~~~~~~
In file included from c:/code/blitzmaxNG710/mod/bah.mod/freeimage.mod/src/LibTIFF4/tiffiop.h:33:0,
                 from c:/code/blitzmaxNG710/mod/bah.mod/freeimage.mod/src/FreeImage/PluginG3.cpp:23:
c:/code/blitzmaxNG710/mod/bah.mod/freeimage.mod/src/LibTIFF4/tif_config.h:84:18: note: previous declaration with 'C++' linkage
 #define snprintf _snprintf
                  ^
[ 14%] Compiling:Resize.cpp
Build Error: failed to compile (1) c:/code/blitzmaxNG710/mod/bah.mod/freeimage.mod/src/FreeImage/PluginG3.cpp

I did notice the same thing about required DLLs though, program (x86) won't run without a few additional DLLs present in the folder, which is hopefully something that can be fixed...

Offline xlsior

  • Jr. Member
  • **
  • Posts: 33
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #16 on: July 30, 2017, 08:06:15 AM »
After some googling, I did find people saying that adding:     -static-libgcc   to the MinGW command statically links the info and remove the dependency on the DLL, but I have no idea how to tell NG to do pass that info along and do that. :-?


Online TomToad

  • Sr. Member
  • ****
  • Posts: 496
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #17 on: July 30, 2017, 10:41:15 AM »
I am not using 7.10, so I can't test this.

In <path-to-ng>/bin, create a file called custom.bmk.  Edit the file with the line
Code: [Select]
addwin32ccopt staticlib -static-libgcc
and save.

When I compile a simple "Hello World" program with Verbose Build, I see bmk calling gcc with this line.
Code: [Select]
C:\TDM-GCC-64/bin/gcc.exe -I"C:/BlitzMaxNG/mod" -I"C:/BlitzMaxNG/mod/brl.mod/blitz.mod" -I"C:/BlitzMaxNG/mod/brl.mod/appstub.mod" -I"C:/BlitzMaxNG/mod/brl.mod/standardio.mod"   -w -DBMX_NG -m64 -ffast-math -fno-exceptions -c -O3 -msse3 -static-libgcc  -g -o "C:/BlitzMaxNG/tmp/.bmx/untitled1.bmx.gui.debug.win32.x64.o" "C:/BlitzMaxNG/tmp/.bmx/untitled1.bmx.gui.debug.win32.x64.c"
Note that -static-libgcc has been added to the command line.  Since I am using TDM-GCC, I can't test if this will add the necessary dlls to the file.
------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline xlsior

  • Jr. Member
  • **
  • Posts: 33
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #18 on: July 30, 2017, 11:27:41 AM »
I see it added to the command line, but it appears to have no noticable effect -- the final .exe is the exact same size as before, and still asks for the DLLs...

Offline Henri

  • Sr. Member
  • ****
  • Posts: 252
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #19 on: July 30, 2017, 12:31:24 PM »
TDM links to libgcc and libstd statically by default. When using different MinGW build, you could try renaming corresponding dll.a files in MinGW-folder to something else in order to force the linker to link statically.

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 469
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #20 on: July 31, 2017, 01:01:12 AM »
This seems similar to Blitzmax legacy upgrading from 4.6 to 4.7+ when you needed to link to libmsvcrt and libgcc with env var "BMK_LD_OPTS = -lmsvcrt -lgcc" so you should try adding to custom.bmk "-static-libmsvcrt".

Offline xlsior

  • Jr. Member
  • **
  • Posts: 33
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #21 on: July 31, 2017, 01:20:14 AM »
This seems similar to Blitzmax legacy upgrading from 4.6 to 4.7+ when you needed to link to libmsvcrt and libgcc with env var "BMK_LD_OPTS = -lmsvcrt -lgcc" so you should try adding to custom.bmk "-static-libmsvcrt".

That didn't work: "gcc.exe: error: unrecognized command line option '-static-libmsvcrt'; did you mean '-static-libasan'?"
 :(

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 469
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #22 on: July 31, 2017, 02:53:35 AM »
No I meant libmsvcrt.a but it must not be there now. The freeimage error looks to be about some deprecated code, searching for __MINGW_ATTRIB_DEPRECATED_SEC_WARN leads to "crt", so a better suggestion is to try adding "-static-libcrtdll".

Offline xlsior

  • Jr. Member
  • **
  • Posts: 33
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #23 on: July 31, 2017, 03:33:45 AM »
No I meant libmsvcrt.a but it must not be there now. The freeimage error looks to be about some deprecated code, searching for __MINGW_ATTRIB_DEPRECATED_SEC_WARN leads to "crt", so a better suggestion is to try adding "-static-libcrtdll".

gcc.exe: error: unrecognized command line option '-static-libcrtdll'; did you mean '-static-libstdc++'?

Looks like there's still differences... Anyway, I skipped freeimage altogether for now, but even without that mod any compiled "hello world" still wants
the following three DLL's to be present:
libgcc_s_sjlj-1.dll
libstdc++-6.dll
libwinpthread-1.dll

Offline SC-Dan37

  • Jr. Member
  • **
  • Posts: 12
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #24 on: August 01, 2017, 05:39:11 PM »
Did some searching and found a -static flag that needs to be set on the linker g++. Currently the verbose output shows this as the g++ command:

g++ -Wl,--stack,4194304 -s  -Wl,--subsystem,windows -mwindows -mthreads -o "C:/path/to/created/executabe.debug.mt.exe" "C:/BmxNG/tmp/ld.tmp"

It needs to be:

g++ -Wl,--stack,4194304 -s -static -Wl,--subsystem,windows -mwindows -mthreads -o "C:/path/to/created/executable.debug.mt.exe" "C:/BmxNG/tmp/ld.tmp"

This worked for me if I run g++ as above in a command prompt.

I tried adding setwin32ccopt static -static to the custom.bmk file to no effect as it puts the -static in the gcc command. Not sure how to add something to the g++ linker command?


Offline markcwm

  • Sr. Member
  • ****
  • Posts: 469
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #25 on: August 01, 2017, 10:14:25 PM »
Compiler commands take 2 arguments, the first is <name> and the second <value>

See https://github.com/bmx-ng/bmk/blob/master/readme.txt
See all NG compiler commands https://github.com/bmx-ng/bmk/blob/master/make.bmk
See "Options for linking" https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/#toc-GCC-Command-Options

I'm not sure if you can omit the <name> argument but try this:
Code: [Select]
addwin32ldopt -static

Offline SC-Dan37

  • Jr. Member
  • **
  • Posts: 12
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #26 on: August 01, 2017, 10:54:47 PM »
Thanks for the information!

I tried adding addwin32ldopt -static: no change.
I tried adding addwin32ldopt static -static. Errors with the following:

C:/BmxNG/MinGW32x64/bin/../lib/gcc/x86_64-w64-mingw32/6.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find static

It looks like its trying to feed static to ld.exe... ? I'm not real familiar with C / C++ compilers and linkers.

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 469
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #27 on: August 02, 2017, 05:08:39 AM »
I'm not so familiar with C++ compilers myself. :o Try for <name> either linker or staticlib, and cross fingers.

Offline SC-Dan37

  • Jr. Member
  • **
  • Posts: 12
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #28 on: August 02, 2017, 05:30:19 PM »
Neither of those worked for me, but I did find in the bmk_util.bmx file where to inject it and have successfully compiled the modified bmk and used it to successfully compile and link exe files for both 64bit and 32bit. I've commented on the issue in Brucey's github site.

Offline xlsior

  • Jr. Member
  • **
  • Posts: 33
Re: Can you use a later build of MinGW64 compiler for Blitzmax NG?
« Reply #29 on: August 02, 2017, 11:01:09 PM »
Neither of those worked for me, but I did find in the bmk_util.bmx file where to inject it and have successfully compiled the modified bmk and used it to successfully compile and link exe files for both 64bit and 32bit. I've commented on the issue in Brucey's github site.

I'm not finding your comment on github -- would you mind either posting a link, or sharing here exactly what you changed to get it to work?


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal