您尚未登录。

楼主 #1 2020-11-29 19:38:49

小果果
会员
注册时间: 2020-05-10
已发帖子: 61
积分: 58.5

求助 buildroot编译好了qt5,新建一个cmake工程,在cmake链接qt5的库出错,链接Ubuntu下qt5的库却没问题

=====================================================================================
CMakeLists.txt 链接Ubuntu下qt5的库

set(CMAKE_C_COMPILER /usr/bin/gcc)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
set(DQT_QMAKE_EXECUTABL /usr/bin/qmake)
set(Qt5Core_DIR /home/xiaoguoguo/Qt5.6.3/5.6.3/gcc_64/lib/cmake/Qt5Core)
find_package(Qt5Core REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt::5Core)

能生成出来Makefile,make之后成功编译。
=====================================================================================
=====================================================================================
CMakeLists.txt 链接buildroot下qt5的库
set(CMAKE_C_COMPILER /home/xiaoguoguo/arm926t/buildroot-2017.11/output/host/bin/arm-926t-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /home/xiaoguoguo/arm926t/buildroot-2017.11/output/host/bin/arm-926t-linux-gnueabi-g++)
set(DQT_QMAKE_EXECUTABL /home/xiaoguoguo/arm926t/buildroot-2017.11/output/host/bin/qmake)
set(Qt5Core_DIR /home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/lib/cmake/Qt5Core/)
find_package(Qt5Core REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt5Core)
Makefile生成失败,提示内容如下

CMake Error at /home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:27 (message):
  The imported target "Qt5::Core" references the file

     "/home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/include/qt5/"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/lib/cmake/Qt5Core/Qt5CoreConfig.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:63 (_qt5_Core_check_file_exists)
  CMakeLists.txt:12 (find_package)


-- Configuring incomplete, errors occurred!
=====================================================================================

Qt5CoreConfig.cmake:27 (message):
  The imported target "Qt5::Core" references the file
根据这个错误提示找到Qt5CoreConfig.cmake:27

25 macro(_qt5_Core_check_file_exists file)
26     if(NOT EXISTS "${file}" )
27         message(FATAL_ERROR "The imported target \"Qt5::Core\" references the file
28    \"${file}\"

然后百度一下第27行,大多数是说该文件的

14    get_filename_component(_qt5Core_install_prefix "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)

这一句有问题。

Qt5CoreConfig.cmake从编译完buildroot就没有更改过,该怎么更正呢?

离线

#2 2020-11-29 19:52:35

raspberryman
会员
注册时间: 2019-12-27
已发帖子: 503
积分: 465

Re: 求助 buildroot编译好了qt5,新建一个cmake工程,在cmake链接qt5的库出错,链接Ubuntu下qt5的库却没问题

用 qt 的 pro.格式工程不香吗?

离线

楼主 #3 2020-11-29 20:42:54

小果果
会员
注册时间: 2020-05-10
已发帖子: 61
积分: 58.5

Re: 求助 buildroot编译好了qt5,新建一个cmake工程,在cmake链接qt5的库出错,链接Ubuntu下qt5的库却没问题

raspberryman 说:

用 qt 的 pro.格式工程不香吗?

有个工程就是cmake个工程,工程好多文件,要把他的工程转成.pro太麻烦了

离线

#4 2020-11-30 09:25:04

ubuntu
会员
注册时间: 2020-03-30
已发帖子: 228
积分: 206

Re: 求助 buildroot编译好了qt5,新建一个cmake工程,在cmake链接qt5的库出错,链接Ubuntu下qt5的库却没问题

cmake 不懂,路过帮顶一下吧

离线

#5 2020-11-30 16:11:01

听风识雨
会员
注册时间: 2020-08-15
已发帖子: 72
积分: 70

Re: 求助 buildroot编译好了qt5,新建一个cmake工程,在cmake链接qt5的库出错,链接Ubuntu下qt5的库却没问题

建议参考buildroot 目录下面的 package/kf5

这个就是依赖 qt5和cmake的工程.

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn