Thread

  1. Re: Issues while building PG in MS Windows, using MSYS2 and MinGW-w64

    Pavlo Golub <pavlo.golub@cybertec.at> — 2018-05-03T14:05:12Z

    Hello, insaf.k.
    
    You wrote:
    
    
    
    ik> Hello,
    
    
    
    ik> I am trying to build PG from source, in MS Windows using MSYS2
    ik> and MinGW-w64. I've tried to build PG 10.0 as wells as 10.3.
    
    Just checked. All compiled in a sane way. I suppose you have some
    environmental problems.
    
    This is my step-by-step guide:
    
    1. Download MSYS2 installer, 64-bit.
    2. Run, choose simple install folder, e.g. C:\msys64
    3. Run MSYS2 after installation and execute:
      pacman -Syu
    4. Maybe you'll need this several times. Close console
    5. Open appropriate console with correct environment:
      a) C:\msys64\msys2_shell.cmd -mingw64
         or
      b) just click on the Start menu “MSYS2 MinGW 64-bit” shortcut
    6. In it update packages:
       pacman -Syu
    7. Install needed packages:
       pacman --needed -S git mingw-w64-x86_64-gcc base-devel
    8. Execute:
    
       git clone git://git.postgresql.org/git/postgresql.git
       cd postgresql
       ./configure --host=x86_64-w64-mingw32 --prefix=/c/pgsql/ && make && make install
    
    Here we tell our target machine will be 64-bit and we want our
    binaries to be copied to C:\pgsql\. 
    
    ik> I've done configuring like this 
    
    ik>       ./configure --prefix="/d/pg10/"
    
    ik> And when I do "make" or "make world", I'm getting compilation
    ik> error. I've attached complete error report at the end of the mail.
    
    
    
    ik> Basically, one error is pre-processor #error must have a working 64-bit integer datatype.
    
    ik> Another error is "redifinition of fseeko".
    
    ik> Another error is "FLEXIBLE_ARRAY_MEMBER" is undefined.
    
    
    
    
    
    ik> I don't know why the error is coming, I tried reinstalling MSYS2
    ik> and but still no luck. Could you please help?
    
    
    ik> My $PATH var is
    
    ik> $ echo $PATH
    ik> /mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
    
    
    
    
    
    
    
    ik> $ make
    ik> make -C src all
    ik> make[1]: Entering directory '/d/Insaf/pgSource/postgresql-10.0/src'
    ik> make -C common all
    ik> make[2]: Entering directory
    ik> '/d/Insaf/pgSource/postgresql-10.0/src/common'
    ik> make -C ../backend submake-errcodes
    ik> make[3]: Entering directory
    ik> '/d/Insaf/pgSource/postgresql-10.0/src/backend'
    ik> make[3]: Nothing to be done for 'submake-errcodes'.
    ik> make[3]: Leaving directory
    ik> '/d/Insaf/pgSource/postgresql-10.0/src/backend'
    ik> gcc -Wall -Wmissing-prototypes -Wpointer-arith
    ik> -Wdeclaration-after-statement -Wendif-labels
    ik> -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing
    ik> -fwrapv -fexce                 ss-precision=standard -O2
    ik> -DFRONTEND -I../../src/include  -I./src/include/port/win32
    ik> -DEXEC_BACKEND  "-I../../src/include/port/win32" -DBUILDING_DLL
    ik> -DVAL_CONFIGURE="\"'--p                 refix=/d/Insaf/pgGcc'
    ik> 'PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig'\""
    ik> -DVAL_CC="\"gcc\"" -DVAL_CPPFLAGS="\"-DFRONTEND
    ik> -I./src/include/port/win32 -DEXEC                 _BACKEND
    ik> "-I../../src/include/port/win32" -DBUILDING_DLL\""
    ik> -DVAL_CFLAGS="\"-Wall -Wmissing-prototypes -Wpointer-arith
    ik> -Wdeclaration-after-statement -Wendif-labels -Wmissin             
    ik> g-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv
    ik> -fexcess-precision=standard -O2\"" -DVAL_CFLAGS_SL="\"\""
    ik> -DVAL_LDFLAGS="\"-L../../src/common -Wl,--allow-                
    ik> multiple-definition -Wl,--disable-auto-import -Wl,--as-needed\""
    ik> -DVAL_LDFLAGS_EX="\"\"" -DVAL_LDFLAGS_SL="\"\""
    ik> -DVAL_LIBS="\"-lpgcommon -lpgport -lz -lws2_32 -lm  -lws2_3        2 \""  -c -o base64.o base64.c
    ik> In file included from ../../src/include/c.h:48:0,
    ik>                  from ../../src/include/postgres_fe.h:25,
    ik>                  from base64.c:18:
    ik> ../../src/include/postgres_ext.h:47:9: error: unknown type name 'PG_INT64_TYPE'
    ik>  typedef PG_INT64_TYPE pg_int64;
    ik>          ^~~~~~~~~~~~~
    ik> In file included from ../../src/include/postgres_fe.h:25:0,
    ik>                  from base64.c:18:
    ik> ../../src/include/c.h:306:2: error: #error must have a working 64-bit integer datatype
    ik>  #error must have a working 64-bit integer datatype
    ik>   ^~~~~
    ik> ../../src/include/c.h:446:15: error: 'FLEXIBLE_ARRAY_MEMBER'
    ik> undeclared here (not in a function)
    ik>   char  vl_dat[FLEXIBLE_ARRAY_MEMBER]; /* Data content is here */
    ik>                ^~~~~~~~~~~~~~~~~~~~~
    ik> In file included from ../../src/include/postgres_fe.h:25:0,
    ik>                  from base64.c:18:
    ik> ../../src/include/c.h:1054:1: warning: 'PG_PRINTF_ATTRIBUTE' is
    ik> an unrecognized format function type [-Wformat=]
    ik>  extern int snprintf(char *str, size_t count, const char
    ik> *fmt,...) pg_attribute_printf(3, 4);
    ik>  ^~~~~~
    ik> In file included from ../../src/include/c.h:1129:0,
    ik>                  from ../../src/include/postgres_fe.h:25,
    ik>                  from base64.c:18:
    ik> ../../src/include/port.h:375:0: warning: "fseeko" redefined
    ik>  #define fseeko(a, b, c) fseek(a, b, c)
    
    ik> In file included from ../../src/include/c.h:101:0,
    ik>                  from ../../src/include/postgres_fe.h:25,
    ik>                  from base64.c:18:
    ik> ../../src/include/pg_config_os.h:237:0: note: this is the
    ik> location of the previous definition
    ik>  #define fseeko(stream, offset, origin) fseeko64(stream, offset, origin)
    
    ik> In file included from ../../src/include/c.h:1129:0,
    ik>                  from ../../src/include/postgres_fe.h:25,
    ik>                  from base64.c:18:
    ik> ../../src/include/port.h:376:0: warning: "ftello" redefined
    ik>  #define ftello(a)  ftell(a)
    
    ik> In file included from ../../src/include/c.h:101:0,
    ik>                  from ../../src/include/postgres_fe.h:25,
    ik>                  from base64.c:18:
    ik> ../../src/include/pg_config_os.h:240:0: note: this is the
    ik> location of the previous definition
    ik>  #define ftello(stream) ftello64(stream)
    
    ik> In file included from ../../src/include/postgres_fe.h:27:0,
    ik>                  from base64.c:18:
    ik> ../../src/include/common/fe_memutils.h:41:1: warning:
    ik> 'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type [-Wformat=]
    ik>  extern char *psprintf(const char *fmt,...) pg_attribute_printf(1, 2);
    ik>  ^~~~~~
    ik> ../../src/include/common/fe_memutils.h:42:1: warning:
    ik> 'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type [-Wformat=]
    ik>  extern size_t pvsnprintf(char *buf, size_t len, const char *fmt,
    ik> va_list args) pg_attribute_printf(3, 0);
    ik>  ^~~~~~
    ik> make[2]: *** [: base64.o] Error 1
    ik> make[2]: Leaving directory
    ik> '/d/Insaf/pgSource/postgresql-10.0/src/common'
    ik> make[1]: *** [Makefile:37: all-common-recurse] Error 2
    ik> make[1]: Leaving directory '/d/Insaf/pgSource/postgresql-10.0/src'
    ik> make: *** [GNUmakefile:11: all-src-recurse] Error 2
    
    
    
    
    
    ik> Regards,
    
    ik> Mohamed Insaf K
    
    
    
    
    
    -- 
    With best wishes,
     Pavlo                          mailto:pavlo.golub@cybertec.at