Openalpr: Unable to compile due to undefined references on Fedora

Created on 2 Oct 2019  路  8Comments  路  Source: openalpr/openalpr

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 to PQsetNoticeProcessor@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 to PQftype@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 to PQgetResult@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 to lo_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 to PQconnectdb@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 to PQresultStatus@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 to PQfinish@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 to PQnfields@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 to PQftable@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 to lo_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 to PQexec@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 to lo_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 to PQcmdStatus@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 to PQgetvalue@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 to lo_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?

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:

/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

All 8 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FSBalbuena picture FSBalbuena  路  10Comments

zohaib-novaturesol picture zohaib-novaturesol  路  3Comments

Mega-Touk picture Mega-Touk  路  11Comments

6mian picture 6mian  路  7Comments

Lepiloff picture Lepiloff  路  6Comments