QtCreator and pkg-config

QtCreator and pkg-config

本文关键字:pkg-config and QtCreator      更新时间:2023-10-16

我将一个makefile项目导入Qt creator,以便进行更高效的开发。当我在终端中使用 make 时:

g++  Size3.o SteerableTests.o MyLib.o Tensor.o Cube.o Steerable.o -lUnitTest++ `pkg-config --libs opencv` -o steerable

它编译成功。但是当使用QtCreator的构建选项时,它一直说pkg-config找不到opencv。如何设置QtCreator的环境路径?

11:35:21: Starting: "/usr/bin/make" all
g++  Size3.o SteerableTests.o MyLib.o Tensor.o Cube.o Steerable.o -lUnitTest++ `pkg-config --libs opencv` -o steerable
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found

我的猜测是环境变量PKG_CONFIG_PATH设置在你的shell中,而不是在QtCreator的环境中。

我能想到的最简单的解决方法是在Makefile中显式设置它,例如

export PKG_CONFIG_PATH=/the/path

要查找/the/path,请尝试在 shell 中echo $PKG_CONFIG_PATH或使用locate(最好)或find查找opencv.pc