PostgreSQL plugin compilation error on OS X

Sorry, got yet another problem. I wanted to give the postgresql plugin a try, but when trying to compile it on OS X I get these errors:

[ 0%] Generating AUTOGENERATED/EmbeddedResources.h, AUTOGENERATED/EmbeddedResources.cpp
Scanning dependencies of target OrthancPostgreSQLIndex
[ 1%] Building CXX object CMakeFiles/OrthancPostgreSQLIndex.dir/Core/PostgreSQLConnection.cpp.o
[ 1%] Building CXX object CMakeFiles/OrthancPostgreSQLIndex.dir/Core/PostgreSQLLargeObject.cpp.o
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Core/PostgreSQLLargeObject.cpp:155:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (nbytes < 0)
            ~~~~~~ ^ ~
1 warning generated.
[ 2%] Building CXX object CMakeFiles/OrthancPostgreSQLIndex.dir/Core/PostgreSQLResult.cpp.o
[ 2%] Building CXX object CMakeFiles/OrthancPostgreSQLIndex.dir/Core/PostgreSQLStatement.cpp.o
[ 3%] Building CXX object CMakeFiles/OrthancPostgreSQLIndex.dir/Core/PostgreSQLTransaction.cpp.o
[ 3%] Building CXX object CMakeFiles/OrthancPostgreSQLIndex.dir/Core/Configuration.cpp.o
[ 4%] Building CXX object CMakeFiles/OrthancPostgreSQLIndex.dir/Core/GlobalProperties.cpp.o
[ 4%] Building C object CMakeFiles/OrthancPostgreSQLIndex.dir/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c.o
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c:23:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/postgres_fe.h:25:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/c.h:1028:
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:408:15: error: expected parameter declarator
extern size_t strlcat(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:111:44: note: expanded from macro 'strlcat'
  __builtin___strlcat_chk (dest, src, len, __darwin_obsz (dest))
                                           ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
# define _USE_FORTIFY_LEVEL 2
                               ^
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c:23:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/postgres_fe.h:25:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/c.h:1028:
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:408:15: error: expected ')'
/usr/include/secure/_string.h:111:44: note: expanded from macro 'strlcat'
  __builtin___strlcat_chk (dest, src, len, __darwin_obsz (dest))
                                           ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
# define _USE_FORTIFY_LEVEL 2
                               ^
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:408:15: note: to match this '('
/usr/include/secure/_string.h:111:44: note: expanded from macro 'strlcat'
  __builtin___strlcat_chk (dest, src, len, __darwin_obsz (dest))
                                           ^
/usr/include/secure/_common.h:39:53: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                    ^
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c:23:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/postgres_fe.h:25:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/c.h:1028:
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:408:15: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern size_t strlcat(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:111:44: note: expanded from macro 'strlcat'
  __builtin___strlcat_chk (dest, src, len, __darwin_obsz (dest))
                                           ^
/usr/include/secure/_common.h:39:31: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                              ^
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c:23:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/postgres_fe.h:25:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/c.h:1028:
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:408:15: error: conflicting types for '__builtin___strlcat_chk'
/usr/include/secure/_string.h:111:3: note: expanded from macro 'strlcat'
  __builtin___strlcat_chk (dest, src, len, __darwin_obsz (dest))
  ^
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:408:15: note: '__builtin___strlcat_chk' is a builtin with type 'unsigned long
      (char *, const char *, unsigned long, unsigned long)'
/usr/include/secure/_string.h:111:3: note: expanded from macro 'strlcat'
  __builtin___strlcat_chk (dest, src, len, __darwin_obsz (dest))
  ^
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c:23:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/postgres_fe.h:25:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/c.h:1028:
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:412:15: error: expected parameter declarator
extern size_t strlcpy(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:105:44: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
                                           ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
# define _USE_FORTIFY_LEVEL 2
                               ^
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c:23:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/postgres_fe.h:25:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/c.h:1028:
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:412:15: error: expected ')'
/usr/include/secure/_string.h:105:44: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
                                           ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
# define _USE_FORTIFY_LEVEL 2
                               ^
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:412:15: note: to match this '('
/usr/include/secure/_string.h:105:44: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
                                           ^
/usr/include/secure/_common.h:39:53: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                    ^
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c:23:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/postgres_fe.h:25:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/c.h:1028:
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:412:15: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern size_t strlcpy(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:105:44: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
                                           ^
/usr/include/secure/_common.h:39:31: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                              ^
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c:23:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/postgres_fe.h:25:
In file included from /Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/c.h:1028:
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:412:15: error: conflicting types for '__builtin___strlcpy_chk'
/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
  ^
/Volumes/Internal/Downloads/OrthancPostgreSQL-2.0/Build/postgresql-9.4.0/src/include/port.h:412:15: note: '__builtin___strlcpy_chk' is a builtin with type 'unsigned long
      (char *, const char *, unsigned long, unsigned long)'
/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
  ^
2 warnings and 6 errors generated.
make[2]: *** [CMakeFiles/OrthancPostgreSQLIndex.dir/postgresql-9.4.0/src/interfaces/libpq/fe-auth.c.o] Error 1
make[1]: *** [CMakeFiles/OrthancPostgreSQLIndex.dir/all] Error 2
make: *** [all] Error 2

Any idea what could be the cause?
Thanks! Regards

Hello,

I don’t have access to a Mac computer so I cannot directly help you, but your issue strongly looks like this one:
https://sourceforge.net/p/postgres-xc/mailman/postgres-xc-bugs/thread/82E44F89-543A-44F2-8AF8-F6909B5DC561@uniud.it/

In this thread, it is suggested that defining the C/C++ macro “_FORTIFY_SOURCE=0” fixes the issue.

I thus suggest you to remove your current build directory, and invoke CMake again as follows:

CXXFLAGS=“-D_FORTIFY_SOURCE=0” CFLAGS=“-D_FORTIFY_SOURCE=0” cmake […your additional CMake flags…]

HTH,
Sébastien-

Thanks! That worked!
Regards