PostgreSQL 16 安装 jieba 全文检索插件报错 for loop initial declarations are only allowed in C99 mode

PostgreSQL pg_jieba 全文检索 About 1,831 words

错误信息

make阶段抛出错误

root@fendoudebb build]# make
Scanning dependencies of target pg_jieba
[ 50%] Building C object CMakeFiles/pg_jieba.dir/pg_jieba.c.o
/home/postgres/pg_jieba/pg_jieba.c:258:1: warning: ‘DefineCustomConfigVariables’ was used with no prototype before its definition [-Wmissing-prototypes]
 DefineCustomConfigVariables()
 ^
In file included from /home/postgres/16.1/include/server/nodes/primnodes.h:22:0,
                 from /home/postgres/16.1/include/server/nodes/parsenodes.h:28,
                 from /home/postgres/16.1/include/server/utils/guc.h:15,
                 from /home/postgres/pg_jieba/pg_jieba.c:17:
/home/postgres/pg_jieba/pg_jieba.c: In function ‘extract_dict_list’:
/home/postgres/16.1/include/server/nodes/pg_list.h:374:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (ForEachState cell##__state = {(lst), 0}; \
  ^
/home/postgres/pg_jieba/pg_jieba.c:459:2: note: in expansion of macro ‘foreach’
  foreach(lc, elemlist)
  ^
/home/postgres/16.1/include/server/nodes/pg_list.h:374:2: note: use option -std=c99 or -std=gnu99 to compile your code
  for (ForEachState cell##__state = {(lst), 0}; \
  ^
/home/postgres/pg_jieba/pg_jieba.c:459:2: note: in expansion of macro ‘foreach’
  foreach(lc, elemlist)
  ^
make[2]: *** [CMakeFiles/pg_jieba.dir/pg_jieba.c.o] Error 1
make[1]: *** [CMakeFiles/pg_jieba.dir/all] Error 2
make: *** [all] Error 2

解决方法

cmake需要安装cmake3版本

yum install cmake3

编辑CMakeLists.txt,添加指令set(CMAKE_C_STANDARD 99)

cd pg_jieba
vi CMakeLists.txt
set(CMAKE_C_STANDARD 99)

cmake 命令

cmake3 -DPostgreSQL_LIBRARY=/home/postgres/16.1/bin -DPostgreSQL_INCLUDE_DIR=/home/postgres/16.1/include -DPostgreSQL_TYPE_INCLUDE_DIR=/home/postgres/16.1/include/server ..

make 命令

cmake3执行完成后,在正常执行makemake install即可。

make
make install

参考

https://www.modb.pro/db/616771

Views: 88 · Posted: 2024-06-05

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh