Search code examples
linuxpostgresqlubuntuluatorch

How to install luasql on Linux Ubuntu 16?


Thanks to the help of the StackOverflow community, I was able to correctly install luasql on my computer running Linux CentOS 7.

Now I have a similar problem on Linux Ubuntu 16. I tried the following commands:

sudo apt-get -y install lua-sql-postgres
sudo apt-get -y install lua-sql-postgres-dev
sudo luarocks install luasql-postgres

And here's the error I get from the system:

Installing https://rocks.moonscript.org/luasql-postgres-2.3.5-2.rockspec...
Using https://rocks.moonscript.org/luasql-postgres-2.3.5-2.rockspec... switching to 'build' mode

Error: Could not find expected file libpq-fe.h, or libpq-fe.h for PGSQL -- 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

Does anyone know how to solve this problem? Thanks


Solution

  • As suggested by @Knud Larsen:

    First, you need to install libpq-dev.

    If it was installed successfully, you can see the file /usr/include/postgresql/libpq-fe.h

    After that execute the command:

    sudo luarocks PGSQL_INCDIR=/usr/include/postgresql/ install luasql-postgres