Question

My OS (Ubuntu 12.04) comes with a pre-packaged Qt4 libraries and other relevant stuffs. But I wanted to use the latest vanilla Qt 5.2.1, I have installed it and it's working fine, suppose I have compiled this framework which depends on Qt.

What I had to do is to add the Qt 5.2.1 libraries to the $LD_LIBRARY_PATH. My Qt 5.2.1 home path is /opt/Qt5.2.1/5.2.1/gcc_64, and thus my $LD_LIBRARY_PATH contains /opt/Qt5.2.1/5.2.1/gcc_64/lib (and /opt/Qt5.2.1/Tools/QtCreator/lib for qtcreator related stuffs)

However, recently I am trying to compile the latest gnu octave. It's configure script looks for the Qt cflags (i.e. -l/-I/-L flags) by invoking the pkg-config.

What I came to know that pkg-config looks for the appropriate .pc files to get the exact information related to all compilation/linking flags. My system (Ubuntu) maintains a list of all required .pc file locations in /var/lib/dpkg/info/pkg-config.list. But I do not have any $PKG_CONFIG_PATH environment variable on Ubuntu 12.04 (I am not sure why).

My newly installed Qt5 has a set of .pc files in /opt/Qt5.2.1/5.2.1/gcc_64/lib/pkgconfig/.

So, how do I make pkg-config to recognize the development libraries in the newly installed Qt 5.2.1 ?

I know that this could be solved by just installing the Qt4 -dev packages from the Ubuntu repo, but I do not want to do that. I need the vanilla Qt 5.2.1 for other purposes.

NOTE:

  • I have added the the path /opt/Qt5.2.1/5.2.1/gcc_64/lib/pkgconfig/ to the pkg-config.list but the pkg-config does not update the compilation flags accordingly.
  • Adding the path (/opt/Qt5.2.1/5.2.1/gcc_64/lib/pkgconfig/) to $PKG_CONFIG_PATH does not work as well.

Here is the octave configure script output.

Était-ce utile?

La solution

This problem is because Octave is searching for QtCore.pc, QtGUI.pc, and QtNetwork.pc but Qt5 seems to have renamed them as Qt5Core.pc, Qt5GUI.pc, and Qt5Network.pc. One solution is to create symlinks for them:

cd /opt/Qt5.2.1/5.2.1/gcc_64/lib/pkgconfig/
ln -s ./Qt5Core.pc ./QtCore.pc
ln -s ./Qt5GUI.pc ./QtGUI.pc
ln -s ./Qt5Network.pc ./QtNetwork.pc
cd octave_build_dir
export $PKG_CONFIG_PATH="/opt/Qt5.2.1/5.2.1/gcc_64/lib/pkgconfig/"
./configure # with fingers crossed

I am unsure of the why the reason of name change. I wonder if there should be some sort of mechanism in place where the unversion versions would be in the $PKG_CONFIG_PATH, and changing your preferences would change the link to correct version.

Finally, your config.log and config.status would have been more useful than just the output of configure. The mentioned files will have the actual commands and output of your configure.

Autres conseils

The carandraug's answer is correct, but I didn't need to symlink .pc files(Qt 5.9.5). To prevent removing other pkg-config addresses, export PKG_CONFIG_PATH like below:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/Qt5.2.1/5.2.1/gcc_64/lib/pkgconfig/

And to execute it at startup and systemwide(no need to export in every terminal session), put these lines at the bottom line in ".bashrc":

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/Qt5.2.1/5.2.1/gcc_64/lib/pkgconfig/
export PKG_CONFIG_PATH
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top