postgresql client library for Lazarus Pascal - missing libpq.dll error - postgresql

I'm trying to create my first application with Lazarus Pascal and PostgreSQL.
The pg database is on my Ubuntu Linux host. Lazarus is on XP, running through VirtualBox.
When trying to make a connection to the PG database, I get an error that libpq.dll is missing.
What should I do? Pretty new to this platform.

From the docs here http://wiki.lazarus.freepascal.org/postgres
Error: "Can not load PostgreSQL client library "libpq.dll""
The program cannot find your PostgreSQL driver files. Copy all required PostgreSQL .dll/.manifest files either
to your project directory and your executable output directory,
or to a directory in your search path (e.g. c:\windows\system32)
A good example that demonstrates how to include drive DLL files when connecting Lazarus with PostgreSQL under Windows is easyDB.
On Linux/Unix/OSX: make sure the PostgreSQL libraries are in your library search path, e.g.:
On linux add the path to the libpq.so file to the libraries section in your /etc/fpc.cfg file. For example : -Fl/usr/local/pgsql/lib
It may be necessary to create a symbolic link from a specific library version to a general library name:
ln -s /usr/lib/pqsql.so.5 /usr/lib/pqsql.so
. Alternatively, install the postgresql client -dev package using your distribution's package manager

Related

Compiling rust pgx package for another operating system

I am trying to compile rust package for timescaleDB. I am using ubuntu and I am trying to compile for centos 7.
https://github.com/timescale/timescaledb-toolkit
After compiling it creates two directory. One called crates.
Another target>release directory.
How do I move this compiled extension to centos and install it in postgres?
You need to copy the files to your postgresql installation folder following your OS directories.
Here you see the docker image adding the timescaledb to the postgresql.conf file.
Here you can see how the sync the extensions folder is just copying the generated files to the machine that will consume the extension.
You'll also need to copy the files over the .sql and .control to your extensions folder.
In my mac it is running with homebrew it is:
/usr/local/share/postgresql/extension/
You can find more details about extension structure here.

Unable to Install DBD::Oracle for Perl on Windows

When trying to install DBD::Oracle library i received the following error message "Can't load /usr/lib/perl5/site_perl/5.24/x86_64-cygwin-threads/auto/DBD/Oracle/Oracle.dll for module DBD::Oracle: No such file directory at /usr/lib/perl5/5.24/x86_64-cygwin-threads/DynaLoader.pm"
I installed the DBD::Oracle library on windows using the below steps:
instantclient-basic-11.2.0.4.0
instantclient-sqlplus-11.2.0.4.0
instantclient-sdk-11.2.0.4.0
Then, I unzip them all to c:\Oracle.
Next, I included the below directory in my system environmental on windows as shown below
ORACLE_HOME=C:\Oracle\instantclient_11_2
LD_LIBRARY_PATH=C:\Oracle\instantclient_11_2\lib (There is no lib directory in this folder, but i followed the instructions of an online article regardless)
Finally, I opened command prompt and ran and received that error message:
perl -MCPAN -e "install DBD::Oracle"
I resolved the problem by installing the 32-bit Oracle Client 11g version onto the computer in this location c:\oracle. It doesn't work using the instantclient version because the instant client doesn't contain the necessary libraries.
Download "Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (32-bit)" from the below link and install the full administrator verion
http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html
Next, create ORACLE_HOME variable in your environmental variables on your computer and add the following path to it: ORACLE_HOME=C:\Oracle\product\11.2.0\client_1
Next, create LD_LIBRARY_PATH variable and add the below path:
LD_LIBRARY_PATH=C:\Oracle\product\11.2.0\client_1\lib
Afterwards, install module using perl without testing it. During the test it will fail, because its trying to connect to your database:
perl -MCPAN -e shell
notest install DBD::Oracle
Open the odbcad32.exe in this location C:\Windows\SysWOW64\ and click Add. Type Oracle for the name and description and click save. The SysWOW64 will connect the 32-bit version of the odbcad32 application to create the reference.
NOTE: The biggest problem you will have is to ensure you are using 32-bit drivers using cygwin, oracle software, and odbcad32. You will receive that can't load library if you mix 64-bit drivers with 32-bit drivers.
Reopen any command prompt window and try running your perl script again.

Can I install postgresql without pgAdmin4?

I was packaging an windows application installer by NSIS.
An postgresql binary file was included in this install package.
But the official binary file is too large 172MB.
The zip archive is download from
https://www.enterprisedb.com/download-postgresql-binaries
The inside structure is like
pgsql
bin
doc
include
lib
pgAdmin4
share
StackBuilder
symbols
In my opinion, pgAdmin4 is no need for my installer.
There are only CRUD operations in between application and SQL.
If I remove this directory, the binary zip can down to 41MB.
So could I simply remove directory pgAdmin4 and re-compress
to achieve this?
So could I simply remove directory pgAdmin4 and re-compress to achieve this?
Yes, and you can remove StackBuilder too if you want. Also symbols if you don't want to do in-place debugging if the postgres server crashes.
Please, please install your bundled PostgreSQL on a non-default port (not 5432) and if you run it as a service use a name associated with your application, so users know where it came from. See Installation of postgresql with NSIS . Put the PostgreSQL install directory within your app install directory.

Installing plpythonu on Windows

I'm trying to install plpython on a postgres server on a Windows machine. When I issue the command CREATE EXTENSION plpython3u; in postgres, I get the following error, which I'm trying to find the source of.
ERROR: could not load library "C:/Program Files/PostgreSQL/9.3/lib/plpython3.dll": The specified module could not be found.
This file exists, which I presume means that Windows can't find one of the files it depends on. When I open the plpython3.dll with Dependency Walker, it tells me it can't locate the GPSVC.dll.
Is it likely that this missing dll would cause the CREATE EXTENSION command to fail? I found a .dll with the same name in C:\Windows\System32 and copied it over to C:\Windows\SysWOW64, but this did not resolve the probelm, and although dependency walker now finds the .dll, it raises several other errors about having modules with different CPU types.
I know this is an old question, but thought I would post to save someone the headaches I went through trying to fix this...
I had the same error trying to add pl python using Postgres 9.5. Dependency walker showed that plpython3.dll was looking for python33.dll, so I installed python 3.3 and added the install directory into my path and that seems to have fixed the problem.
Use specific python version on Windows. I could get it running with python 3.2.x with postgres 9.3

Where do I get libpq source?

I want to write application which uses Postgresql as DBMS.
To write client application do I need libpq library and header files?
If yes where I would get libpq library and header files.
Libpq is included in the full PostgreSQL source code. You can use just libpq without the rest of PostgreSQL, but must download the full package.
You can download it from the PostgreSQL Downloads page.
Once you extract the full package it is inside src\interfaces\libpq.
The PostgreSQL installation guide details how to install only the client libraries in the Installation section, under Client-only installation.
Libpq documentation is also available.
In postgresql sources, src\interfaces\libpq.
And yes, it is possible to compile only the libpq.
get the lipq from repo, {for debian} :
sudo apt-get install libpq-dev
I was also facing this issue but didn't got a clear answer:
This issue clearly states that while installing diesel-cli system is not able to locate libpq.lib
First of all you should have a Postgres installed on your machine.
Also diesel require visual c++, thus download and install it if not already, the size of setup will be ~5gb.
Once above installations are done you need to setup environment variables:
In my case path of Postgres installation is C:\Program Files\PostgreSQL thus add 2 environment variable path under User variables add new in Path where your libpq.lib is located in my case it is available in both C:\Program Files\PostgreSQL\12\lib and C:\Program Files\PostgreSQL\12\bin
Once this is added create one more environment variable PQ_LIB_DIR and set path as shown below
Note: Once done re-trigger the installation command in a new cmd window
Source: pq-sys and github-solution
For Windows users, it's in (version may be different)
C:\Program Files\PostgreSQL\11\lib
There you find libpq.lib. Provide this directory to Linker input.
Don't forget to include C:\Program Files\PostgreSQL\11\include directory for include directories.
I fix this problem reccently. This is a solution if you don't want to install Postgres in you windows.
At first, you need download Postgres Binaries. The version I download is 13.6, but it's seems like any version is fine.
Unzip the zip file.Copy libpq.lib from pgsql\lib to shomewhere like C:\Program Files\Postgres\lib.
Execute the following command in cmd window.
setx PQ_LIB_DIR "{where_you_copy_to}"
Open a new cmd windows and install diesel_cli
cargo install diesel_cli --no-default-features --features postgres
In linux vertify you get the libpq.
1st, there is an app: pg_config: https://www.postgresql.org/docs/current/app-pgconfig.html
after you found out the pg_config absolute bin path.(if you installed multi version of postgressql) Then You can get
--includedir
Print the location of C header files of the client interfaces.
--libdir
Print the location of object code libraries.
Then try to compile/build some example code: https://www.postgresql.org/docs/current/libpq-example.html
Some common failure example: https://www.postgresql.org/docs/current/libpq-build.html
You can install Postgres locally from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads but select only "Command line tools" for install.
After that, you can found libpq.dll in C:\Program Files\PostgreSQL\15\bin