Skip to content

mingw64 compiling failure #8825

Closed
Closed

Description

@JouSF-1409

I use mingw64 from msys2 and occurs several warnings and 1 fatal.

a warning is related with macro redefinition in gmt_io.h. In my case, fseek and ftell are defined twice.

#ifdef HAVE_FSEEKO
#	define fseek fseeko
#endif

#ifdef HAVE_FTELLO
#	define ftell ftello
#endif

/* Windows 64-bit file access */
#if defined HAVE__FSEEKI64 && defined HAVE__FTELLI64
#	define fseek _fseeki64
#	define ftell _ftelli64
#	ifndef SIZEOF_OFF_T
		typedef __int64 off_t;
#	else
#		define off_t __int64
#	endif /* SIZEOF_OFF_T */
#elif !defined SIZEOF_OFF_T /* HAVE__FSEEKI64 && HAVE__FTELLI64 */
	typedef long off_t;
#endif /* HAVE__FSEEKI64 && HAVE__FTELLI64 */

1 fatal is in gmt_plot.c

C:/software/msys2/home/13967/opt/src_gmt/src/gmt_plot.c: In function 'gmtlib_read_ps':
C:/software/msys2/home/13967/opt/src_gmt/src/gmt_plot.c:10717:33: error: passing argument 2 of 'fstat' from incompatible pointer type [-Wincompatible-pointer-types]
10717 |                 if (fstat (*fd, &buf)) {
      |                                 ^~~~
      |                                 |
      |                                 struct _stat64 *
In file included from C:/software/msys2/home/13967/opt/src_gmt/src/gmt_notposix.h:83,
                 from C:/software/msys2/home/13967/opt/src_gmt/src/gmt_dev.h:139:
C:/software/msys2/mingw64/include/sys/stat.h:166:43: note: expected 'struct stat *' but argument is of type 'struct _stat64 *'
  166 | int __cdecl fstat(int _Desc, struct stat *_Stat) __MINGW_ASM_CALL(_fstat64i32);
      |                              ~~~~~~~~~~~~~^~~~~
ninja: build stopped: subcommand failed.

i change fstat to _fstat64 and _stat64 to stat and all compile passed

$ ./gmt.exe

        GMT - The Generic Mapping Tools, Version 6.7.0_bf5ba5b-dirty_2025.11.03 [64-bit] [MP] [16 cores]
        (c) 1991-2025 The GMT Team (https://www.generic-mapping-tools.org/team.html).

        Supported in part by the US National Science Foundation (http://www.nsf.gov/)
        and volunteers from around the world.

        GMT is distributed under the GNU LGPL License (http://www.gnu.org/licenses/lgpl.html).
        Dependencies: netCDF, GDAL, PCRE, FFTW, LAPACK, ZLIB, Ghostscript, GraphicsMagick, FFmpeg.

usage: gmt [options]
       gmt <module name> [<module-options>]

options:
  --help              List descriptions of available GMT modules.
  --new-script[=L]    Write GMT modern mode script template to standard output.
                      Optionally specify bash|csh|batch [Default is current shell].
  --new-glue=name     Write C code for external supplements to glue them to GMT.
  --show-bindir       Show directory with GMT executables.
  --show-citation     Show the most recent citation for GMT.
  --show-classic      Show all classic module names.
  --show-classic-core Show all classic module names (core only).
  --show-cores        Show number of available cores.
  --show-datadir      Show directory/ies with user data.
  --show-dataserver   Show URL of the remote GMT data server.
  --show-date         Show GMT binary building date
  --show-dcw          Show the DCW data version used.
  --show-doi          Show the DOI for the current release.
  --show-gshhg        Show the GSHHG data version used.
  --show-library      Show path of the shared GMT library.
  --show-modules      Show all modern module names.
  --show-modules-core Show all modern module names (core only).
  --show-plugindir    Show directory for plug-ins.
  --show-sharedir     Show directory for shared GMT resources.
  --show-userdir      Show full path of user's ~/.gmt dir
  --version           Print GMT version number.

if <module-options> is '=' we call exit (0) if module exist and non-zero otherwise.

My env is as down below.

*  GMT Version:               : 6.7.0_bf5ba5b-dirty_2025.11.03
*  System:                    : Windows (10.0.26100)
*
*  Options:
*  Found GSHHG database       : C:/software/msys2/home/13967/opt/src_gmt/share/gshhg-gmt (2.3.7)
*  Found DCW-GMT database     : C:/software/msys2/home/13967/opt/src_gmt/share/dcw-gmt (2.2.0)
*  Found GMT data server      : oceania
*  NetCDF library             : C:/software/msys2/mingw64/lib/libnetcdf.dll.a
*  NetCDF include dir         : C:/software/msys2/mingw64/include
*  Curl library               : CURL::libcurl
*  Curl include dir           :
*  GDAL library               : C:/software/msys2/mingw64/lib/libgdal.dll.a
*  GDAL include dir           : C:/software/msys2/mingw64/include
*  GEOS library               : C:/software/msys2/mingw64/lib/libgeos_c.dll.a
*  GEOS include dir           : C:/software/msys2/mingw64/include
*  FFTW library               : C:/software/msys2/mingw64/lib/libfftw3f.dll.a
*  FFTW threads library       : C:/software/msys2/mingw64/lib/libfftw3f_threads.dll.a
*  FFTW include dir           : C:/software/msys2/mingw64/include
*  Accelerate Framework       :
*  Regex support              : PCRE (C:/software/msys2/mingw64/lib/libpcre.dll.a)
*  ZLIB library               : C:/software/msys2/mingw64/lib/libz.dll.a
*  ZLIB include dir           : C:/software/msys2/mingw64/include
*  LAPACK library             : yes
*  BLAS library               : yes
*  License restriction        : no
*  Triangulation method       : Shewchuk
*  OpenMP support             : enabled
*  GLIB GTHREAD support       : enabled
*  Build generator            : Ninja
*  Build GMT core             : always [gmt.dll]
*  Build PSL library          : always [postscriptlight.dll]
*  Build GMT supplements      : yes [supplements.dll]
*  Build GMT for developers   : yes
*  Build proto supplements    : none
*  Build module links         : no
*  Found Ghostscript (gs)     : yes
*  Found GraphicsMagick (gm)  : yes (1.3.45)
*  Found ffmpeg               : no
*  Found open                 : yes
*  Found ogr2ogr              : yes (3.11.4)
*  Found gdal_translate       : yes (3.11.4)
*
*  Locations:
*  Installing GMT in          : C:/software/msys2/home/13967/opt/gmt
*  GMT_DATADIR                : C:/software/msys2/home/13967/opt/gmt/share
*  GMT_DOCDIR                 : C:/software/msys2/home/13967/opt/gmt/share/doc
*  GMT_MANDIR                 : C:/software/msys2/home/13967/opt/gmt/share/man
-- Configuring done (64.4s)
-- Generating done (0.2s)

Activity

  1. added
    bug
    on Nov 9, 2025
  2. joa-quim commented on Nov 9, 2025

    @joa-quim
    Member

    I've been seeing that issue for years in MSVC but it has always been innocuous. But maybe some GCC change has made it more strict now.

    Created issue #8826. See if it fixes it for you.

  3. JouSF-1409 commented on Nov 10, 2025

    @JouSF-1409
    Author

    compile passed. Thanks.
    I dont think _WIN32 is that exactly, maybe __MINGW32__

  4. joa-quim commented on Nov 10, 2025

    @joa-quim
    Member

    No, I want it to be as is to include also the MSVC compilation and restrict the change to 64 bits, which from its name, is what _fstat64 is.

  5. JouSF-1409 commented on Nov 10, 2025

    @JouSF-1409
    Author

    oh, I just thought _fstat64 is for MinGW only. I have found it in msvc docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions