如何在Linux CentOS 7上安装luasql?

我尝试使用以下命令在我的Linux CentOS 7计算机上安装luasql

luarocks install luasql-postgres

但不幸的是,我遇到了以下错误:

Installing https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luasql-postgres-2.3.5-2.rockspec...
Using https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luasql-postgres-2.3.5-2.rockspec... switching to 'build' mode

Error: Could not find header file for PGSQL
  No file libpq-fe.h in /usr/local/include
  No file libpq-fe.h in /usr/include
You may have to install PGSQL in your system and/or pass PGSQL_DIR or PGSQL_INCDIR to the luarocks command.
Example: luarocks install luasql-postgres PGSQL_DIR=/usr/local

然后我尝试运行最后一行luarocks install luasql-postgres PGSQL_DIR=/usr/local,但是没有任何改进...

我该怎么做?

点赞
用户6020403
用户6020403
Lua部分已经没有问题了;你现在遇到的错误是由于缺少C位。

通常情况下,当你与C库进行交互时,你需要确保已经安装了C库的-dev(对于Debianish系统)或-devel(对于Redhatish系统)包。

在你的情况下,你可以在你的机器上以root身份执行以下命令:

yum install postgresql-devel


然后再次尝试luarocks的安装就可以了。

或者,你也可以尝试使用操作系统本身的包:

yum install lua-sql-postgresql


我个人偏向于使用操作系统本身的包来安装那些不经常改变的稳定的Lua库,但最终决定还是取决于你。 
2017-04-02 20:01:07