opencv - 无需重新编译即可重新生成 pkg-config 文件“opencv.pc”
问题描述
我在我创建的子目录中使用以下命令在 Raspbian 上编译了 OpenCV 库(版本 4):
cmake -D CMAKE_INSTALL_PREFIX=./ -D CMAKE_BUILD_TYPE=Debug ../
make -j4
make install
我正在使用 pkg-config 文件opencv.pc
来编译一个带有Makefile
.
我不得不将库文件夹移动到另一个目录,以便文件opencv.pc
指向错误的路径。但是动态库应该仍然有效(不是吗?)。
那么如何在opencv.pc
不重新编译 Raspbian 上的所有库的情况下重新生成文件,这需要大量时间?
编辑 1
尝试重新运行cmake -D CMAKE_INSTALL_PREFIX=./ -D CMAKE_BUILD_TYPE=Debug ../
会导致以下错误:
CMake Error: The current CMakeCache.txt directory /home/pi/opencv-2.4.13/build/CMakeCache.txt is different than the directory /home/pi/OldDirectory/opencv-2.4.13/build/ where CmakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure reedit CMakeCache.txt
CMake Error The source "NewSourcePath" does not match the source "NewSourcePath" used to generate cache. Re-run cmake with a different source directory.
解决方案
我不得不将库文件夹移动到另一个目录,以便文件 opencv.pc 指向错误的路径。但是动态库应该仍然有效(不是吗?)。
您的.pc
文件应使用相对于其自身位置的路径。这样,它就可以安全地搬迁。例如,
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${prefix}/include
includedir=${prefix}/lib64
Name: Proton
Description: Qpid Proton C library
Version: 0.36.0
URL: http://qpid.apache.org/proton/
Libs: -L${libdir} -lqpid-proton
Cflags: -I${includedir}
诀窍是${pcfiledir}
变量。因此,编写良好的.pc
文件将“正常工作”。如果文件使用绝对路径,您可以使用查找和替换方法,将指向先前库位置的前缀替换为您现在拥有库的新前缀。
推荐阅读
- python - 如何在熊猫数据框中执行不同值的累积和
- clang - 如何停止 clang AST 将这种类型的函数声明误解为变量声明?
- php - 为什么 Laravel 广播事件总是使用“laravel_database_channel”频道以及如何更改它?
- reactjs - 为什么 Input onChange 的行为类似于 ReactJs 中的 onKeyDown?
- python - 如何将 sklearn 管道转换为普通代码?
- c# - 如何使用 Marshal.CreateWrapperOfType(非过时版本)从 Com 对象转换为 Outlook 类型
- amazon-web-services - Amazon S3/EMR 中的 Parquet 下推过滤器
- r - ggplot 与 ggsave(width=x, height=y) 具有相同的宽度和高度
- c++ - 动态车辆建模与仿真启动条件
- docker - 如何通过 ssh 将 docker 镜像“rsync”到远程主机?