CMake /usr/bin/ld: cannot find -lQtScript
I have a existing Qt 4.8.2 project where I had to QtScript support. The project is build with cmake.
I added the QtScript lib bby ```
find_package(Qt4 REQUIRED QtScript QtCore QtGui QtXml)
This works fine for compiling but when the linker starts I get every time:
/usr/bin/ld: cannot find -lQtScript collect2: error: ld returned 1 exit status make: *** [...] Error 1 make: *** [...] Error 2 make: *** [all] Error 2
Since compiling works find_package() should have worked. What I don't understand is why das linking not work when find_package() must have found QtScript already. Has someone any ideas?
Pretty strange indeed. Did you check that you have the QtScript dev package installed ?
dpkg -l | grep libqt4*
ii libqt4-script:amd64 4:4.8.2+dfsg-11 amd64 Qt 4 script module rc libqt4-script:i386 4:4.8.2+dfsg-11 i386 Qt 4 script module
it seams to me it is available. However I didn't see a *script-dev version.
Aren't you then missing the
libqt4-devpackage from your system ?
@SGaist libqt4-dev is listed I just forgot to mention it.
I got one step closer to the solution. It seams that the cmake script used the non commercial qt 4.8.2 version instate of the also installed commercial 4.8.2 version.
I added just to test it
With this added the progamm is compiled and linked successfully. The problems now is that I get warnings that no safe linker search path for the target could be created because some how now the script finds both the ones in the commercial directory and the one in /sr/lib/x86_64-linux-gnu.
I think i have to find the right envirmental variable to make it right. Thanks for your help.
IIRC, you can use
CMAKE_PREFIX_PATHwhen calling qmake to make it found your other Qt version first.
By the way, are you locked to 4.8.2 ? If not, you should at least update to 4.8.7 which is the latest and last of the Qt 4 series or better go with Qt 5.
@SGaist thx I will try that. I have to check if I can use Qt5 I think we have a non version bound license but at the moment its kind of a "never touch a running system" situation"