My system is Fedora, I followed the install instructions at https://github.com/openalpr/openalpr/wiki/Compilation-instructions-(Fedora-Linux). However, command make fails due to the following error:
[ 53%] Linking CXX executable alprd
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQsetNoticeProcessor@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQputCopyEnd@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQftype@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference tolo_read@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQgetResult@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQclear@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference tolo_open@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQntuples@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQconnectdb@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQescapeStringConn@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQresultStatus@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQgetlength@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQfinish@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQerrorMessage@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQnfields@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQfname@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQftable@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQftablecol@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference tolo_close@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQfmod@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQexec@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQsetClientEncoding@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference tolo_write@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQexecParams@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQcmdStatus@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQstatus@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQgetvalue@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQgetisnull@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference tolo_creat@RHPG_9.6' /usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference toPQputCopyData@RHPG_9.6'
/usr/bin/ld: //usr/lib64/libgdal.so.20: undefined reference to `PQresultErrorMessage@RHPG_9.6'
collect2: error: ld returned 1 exit status
make[2]: * [CMakeFiles/alprd.dir/build.make:185: alprd] Error 1
make[1]: [CMakeFiles/Makefile2:75: CMakeFiles/alprd.dir/all] Error 2
make: ** [Makefile:152: all] Error 2
Any ideas on what I may be missing or how to proceed?
The issue seems to be unrelated to OpenALPR.
I reopen this issue because I had a similar problem when trying to compile ttk on Fedora 30.
Here is a similar stack trace I got when compiling:
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQfname@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQresStatus@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQftype@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQexec@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQfformat@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQclear@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQntuples@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQstatus@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQconnectdb@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQescapeStringConn@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQgetvalue@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQgetisnull@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQresultStatus@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQfinish@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQerrorMessage@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQnfields@RHPG_9.6'
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1: undefined reference to `PQresultErrorMessage@RHPG_9.6'
Though some symbols were referenced when inspecting the library /usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1 (this can be inspected with objdump, readelf or nm, see the bottom of this comment) it seems that this was rather due to missing a library version within libpg:
$ ldd /usr/lib64/vtk/libvtkIOPostgreSQL.so.1
/usr/lib64/vtk/libvtkIOPostgreSQL.so.1: /usr/pgsql-12/lib/libpq.so.5: no version information available (required by /usr/lib64/vtk/libvtkIOPostgreSQL.so.1)
# ...
libpq.so.5 => /usr/pgsql-12/lib/libpq.so.5 (0x00007fa9b39c0000)
# ...
On my machine, this latter version was provided by several devel packages for PostGreSQL 12, namely:
$ dnf provides /usr/pgsql-12/lib/libpq.so
postgresql12-devel-12rc1-2PGDG.f30.x86_64 : PostgreSQL development header files and libraries
Repo : pgdg12
Matched from:
Filename : /usr/pgsql-12/lib/libpq.so
postgresql12-devel-12.0-1PGDG.f30.x86_64 : PostgreSQL development header files and libraries
Repo : @System
Matched from:
Filename : /usr/pgsql-12/lib/libpq.so
postgresql12-devel-12.0-1PGDG.f30.x86_64 : PostgreSQL development header files and libraries
Repo : pgdg12
Matched from:
Filename : /usr/pgsql-12/lib/libpq.so
# ...
I uninstalled them and it resolves my problem:
$ sudo dnf erase postgresql12-devel-12.0-1PGDG.f30.x86_64
$ sudo dnf erase postgresql11-libs-11.5-1PGDG.f30.x86_64
$ sudo dnf erase postgresql12-libs-12.0-1PGDG.f30.x86_64
# ...
@tmscer : you might want to try commands like those ones to inspect your library, /usr/lib64/libgdal.so.20:
$ objdump -gC /usr/lib64/libgdal.so.20
$ objdump -g /usr/lib64/libgdal.so.20
$ readelf -Ws /usr/lib64/libgdal.so.20 | grep '^\([[:space:]]\+[^[:space:]]\+\)\{6\}[[:space:]]\+[[:digit:]]\+'
$ nm --demangle --dynamic /usr/lib64/libgdal.so.20
I solved the same issue on a Fedora 31 system by:
# rm /etc/ld.so.conf.d/postgresql-pgdg-libs.conf
# ldconfig /usr/lib64
The reason for the warnings is that Postgres installs two versions of libpq, one in /usr/pgsql-12/lib and another in /usr/lib64:
$ rpm -qfi /usr/lib64/libpq.so.5.12 /usr/pgsql-12/lib/libpq.so.5.12 | pcregrep '^(Name|Version|Release)'
Name : libpq
Version : 12.2
Release : 1.fc31
Name : postgresql12-libs
Version : 12.2
Release : 2PGDG.f31
And with the custom ld.so.conf snippet which contains /usr/pgsql-12/lib/ the preferred libpq ends up being the version-specific one in /usr/pgssql-12. But since the executables in /usr/pgsql-12/bin all have explicit RUNPATH settings, and almost everything else on the system expects the "generic" library from /usr/lib64, the custom ld.so.conf setting is counter-productive.
$ readelf -d /usr/pgsql-12/bin/psql | pcregrep 'RUNPATH|libpq'
0x0000000000000001 (NEEDED) Shared library: [libpq.so.5]
0x000000000000001d (RUNPATH) Library runpath: [/usr/pgsql-12/lib]
Removing it solves the problem.
You can check with ldconfig -p | grep libpq.
I got a problem building Caffe and turns out it's because of this as well saying 'undefined reference to `PQ' ..
Thanks mate!!
Hi, I get the same output when compile QField
...
/usr/bin/ld: /usr/lib64/libgdal.so.26: undefined reference to `PQfname@RHPG_9.6'
....
I follow this issue and try erase /usr/pgsql-12/lib/libpq.so.5, but PostgreSQL uninstall. Then I reinstall Postgres server and client.
The problem persist :(
Finally, I remove all repos for Postgres (e.g PostgreSQL Yum Repository) and install default PostgreSQL in RPMs. This works for me.
Thanks! @jlgranda I meet the same problem.
Finally I found it caused by the libpq provided by pgdg-common repo. I solved my problem by reinstalling the libpq using the default repo (AppStream).
sudo yum remove pgdg-redhat-repo.noarch
sudo yum install gdal gdal-devel
Yeah!
Most helpful comment
I reopen this issue because I had a similar problem when trying to compile ttk on Fedora 30.
Here is a similar stack trace I got when compiling:
Though some symbols were referenced when inspecting the library
/usr/bin/ld: /usr/lib64/vtk/libvtkIOPostgreSQL.so.1(this can be inspected withobjdump,readelfornm, see the bottom of this comment) it seems that this was rather due to missing a library version withinlibpg:On my machine, this latter version was provided by several
develpackages for PostGreSQL 12, namely:I uninstalled them and it resolves my problem:
@tmscer : you might want to try commands like those ones to inspect your library,
/usr/lib64/libgdal.so.20: