【问题标题】:Upgrading from Postgres 10 to 11 with Postgis使用 Postgis 从 Postgres 10 升级到 11
【发布时间】:2019-02-13 16:40:29
【问题描述】:

我最近不得不在我的 macOS Mojave 上使用 homebrew 从 Postgres 版本从 10 升级到 11,并且由于需要使用 Postgis,因此在升级后遵循使用 brew postgresql-upgrade-database 的标准方式看起来并不是那么简单Postgres 版本。

我发现this gist 看起来几乎可以解决我的问题。当我尝试在postgis-2.5.1 上运行make 时,它会抛出一个错误,似乎将Command Line Tools 与我目前尚未安装的Xcode 路径混淆了。

下面我粘贴了到目前为止我尝试过的命令序列:

❯ xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk

❯ ./configure --with-pgconfig=/usr/local/Cellar/postgresql@10/10.6_1/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.9_2/bin/xml2-config --with-projdir=/usr/local/Cellar/proj/5.2.0 --with-jsondir=/usr/local/Cellar/json-c/0.13.1 --with-pcredir=/usr/local/Cellar/pcre/8.4

❯ make
/usr/local/bin/perl utils/svn_repo_revision.pl
Can't fetch local revision (neither .svn nor .git found)
Not updating existing rev file at 17027
for s in liblwgeom libpgcommon postgis regress raster topology loader utils doc extensions; do \
                echo "---- Making all in ${s}"; \
                /Library/Developer/CommandLineTools/usr/bin/make -C ${s} all || exit 1; \
        done;
---- Making all in liblwgeom
make[1]: Nothing to be done for `all'.
---- Making all in libpgcommon
make[1]: Nothing to be done for `all'.
---- Making all in postgis
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I../liblwgeom -g -O2 -I../libpgcommon  -I/usr/local/Cellar/geos/3.7.1_1/include -I/usr/local/Cellar/proj/5.2.0/include  -I/usr/local/Cellar/libxml2/2.9.9_2/include/libxml2 -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I/usr/local/Cellar/json-c/0.13.1/include -I/usr/local/Cellar/pcre/8.42/include  -fPIC -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I. -I./ -I/usr/local/Cellar/postgresql@10/10.6_1/include/server -I/usr/local/Cellar/postgresql@10/10.6_1/include/internal -I/usr/local/Cellar/icu4c/63.1/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2   -c -o postgis_module.o postgis_module.c
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
In file included from postgis_module.c:26:
In file included from /usr/local/Cellar/postgresql@10/10.6_1/include/server/postgres.h:47:
/usr/local/Cellar/postgresql@10/10.6_1/include/server/c.h:81:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
make[1]: *** [postgis_module.o] Error 1
make: *** [all] Error 1

即使我在./configure 上明确设置sysroot 路径或在发出make 之前设置CMAKE_OSX_SYSROOT,它也不起作用。

❯ ./configure --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/ --with-pgconfig=/usr/local/Cellar/postgresql@10/10.6_1/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.9_2/bin/xml2-config --with-projdir=/usr/local/Cellar/proj/5.2.0 --with-jsondir=/usr/local/Cellar/json-c/0.13.1 --with-pcredir=/usr/local/Cellar/pcre/8.4

❯ CMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk make
/usr/local/bin/perl utils/svn_repo_revision.pl
Can't fetch local revision (neither .svn nor .git found)
Not updating existing rev file at 17027
for s in liblwgeom libpgcommon postgis regress raster topology loader utils doc extensions; do \
                echo "---- Making all in ${s}"; \
                /Library/Developer/CommandLineTools/usr/bin/make -C ${s} all || exit 1; \
        done;
---- Making all in liblwgeom
make[1]: Nothing to be done for `all'.
---- Making all in libpgcommon
make[1]: Nothing to be done for `all'.
---- Making all in postgis
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I../liblwgeom -g -O2 -I../libpgcommon  -I/usr/local/Cellar/geos/3.7.1_1/include -I/usr/local/Cellar/proj/5.2.0/include  -I/usr/local/Cellar/libxml2/2.9.9_2/include/libxml2 -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I/usr/local/Cellar/json-c/0.13.1/include -I/usr/local/Cellar/pcre/8.42/include  -fPIC -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I. -I./ -I/usr/local/Cellar/postgresql@10/10.6_1/include/server -I/usr/local/Cellar/postgresql@10/10.6_1/include/internal -I/usr/local/Cellar/icu4c/63.1/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2   -c -o postgis_module.o postgis_module.c
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
In file included from postgis_module.c:26:
In file included from /usr/local/Cellar/postgresql@10/10.6_1/include/server/postgres.h:47:
/usr/local/Cellar/postgresql@10/10.6_1/include/server/c.h:81:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
make[1]: *** [postgis_module.o] Error 1
make: *** [all] Error 1

作为记录,我已经安装了 macOS_SDK_headers_for_macOS_10.14.pkg 我发现 herehere 可能是必需的。

我非常感谢任何关于我可能做错了什么的线索或提示或任何其他可以解决问题的方法。

谢谢!

【问题讨论】:

  • 你有没有偶然在 StackOverflow 之外得到过这个问题的答案?经过相同的步骤后,我遇到了同样的问题。
  • @mattdeboard 刚刚在下面报道。希望这对你有用!

标签: xcode postgresql clang homebrew postgis


【解决方案1】:

经过一番挣扎,我最终完全抛弃了旧数据库:

pg_dumpall > /tmp/my_databases.sql

然后安装新的 Postgres 并使用以下命令将所有数据恢复到新版本:

psql -f /tmp/my_databases.sql

希望以后能帮到别人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-17
    • 1970-01-01
    • 1970-01-01
    • 2020-02-27
    • 2014-05-18
    • 2016-05-11
    相关资源
    最近更新 更多