QT配置cmake 报错:Cannot specify link libraries for target " XXX XXX " which is not built by this project.或The keyword signature for target_link_libraries has already been used with the target

报错 Cannot specify link libraries for target " XXX XXX " which is not built by this project
是因为在使用target_link_libraries的时候,没有放到add_executable后面.
然而qt项目中的cmakelist.txt已经自动帮你写过add_executable了,所以如果自己加上add_executable又会报错有同名文件被添加。
image
特别注意一个项目中所有链接库要么都是Private要么都不是,如蓝色框框所示,否则会报错
The keyword signature for target_link_libraries has already been used with the target

顺便提一下cmake编译opencv源码

cmake-gui中选择本地编译器,.../qt/tools/mingwxx/bin中,c选择gcc.exe,c++选择g++.exe,选择advance模式,搜索cmake_make_program选择mingw32make.exe,都在前面所说的路径下,并把.../qt/tools/mingwxx/bin添加到系统环境变量Path中,提前下载opencv_videoio_ffpeg.dll并放入opencv4.6.0\sources\3rdparty\ffmpeg下

posted @   Los1r  阅读(3034)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
点击右上角即可分享
微信分享提示