[Interest] link error (and probably a dumb question)

René J. V. Bertin rjvbertin at gmail.com
Wed Sep 16 15:52:48 CEST 2015

Andreas Pakulat wrote:

> So if you do have another Qt5Core on your system, maybe a slightly
> different version, then that would explain the linking errors when you use
> just -lQt5Core -lQt5Sql. It also explains possible issues when you use
> -lQt5Core /path/to/libQt5Sql.so, since the Qt5Sql is from a different
> version of qt it may require other symbols than are in Qt5Core (in
> particular if a newer Qt5Sql is used with an older Qt5Core).

Doh, I was certain that I actually knew the (likely) answer. Evidently I do have 
an older version around that the linker picks up; being on a Kubuntu 14.04 
system that's /usr/lib/x86_64-linux-gnu/libQt5Core.so (Qt 5.2.1) 
That dirname is specified with -L in order to find the sqlite3 library (needlessly 
so in fact), and thus the search for libQt5Core.so also starts there.

An option I recalled (probably from longer than 12y ago ;)) that makes ld print 
out what libraries it pulls in (i.e. the search resolution), confirmed this.

Indeed, when I remove the -L/usr/lib/x86_64-linux-gnu argument from the failing 
link command it no longer fails, so thank you Andreas for pointing out something 
I simply missed among all the other options.

Question is now, how to teach Qt's build system that /usr/lib/x86_64-linux-gnu 
(and /usr/lib/i386-linux-gnu) is a location that's looked in by default on 
Debuntu... (the -L flag is *not* provided by pkg-config).


More information about the Interest mailing list