我使用qt official example并收到错误:
/media/roroco/disk750/Downloads/qtbase/examples/widgets/desktop/systray/main.cpp:50: undefined reference to `qInitResources_systray()'
这是我的CMakeLists.txt
SET(CMAKE_PREFIX_PATH /media/roroco/disk750/Downloads/qtbase)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Widgets)
add_executable(systray main.cpp window.cpp)
target_link_libraries(systray Qt5::Widgets)
如何使此示例正常工作
答案 0 :(得分:1)
根据错误消息undefined reference to `qInitResources_systray()'
,我应该使用以下CMakeLists.txt
cmake_minimum_required(VERSION 3.3)
project(systray)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
SET(CMAKE_PREFIX_PATH /media/roroco/disk750/Downloads/qtbase)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5Widgets)
add_executable(systray main.cpp window.cpp systray.qrc)
target_link_libraries(systray Qt5::Widgets)