问题
I'm currently working on a project where Qt5Charts is used in a linux platform. By default there was qt5.5 in the system. I have installed qt5.8 in my home directory.
To build the project I'm using cmake. My Cmakefile looks something like this
find_package(Qt5Widgets)
set(CMAKE_AUTOMOC ON)
if(Qt5Widgets_FOUND)
set( QT_INCLUDE_DIR
${Qt5Widgets_INCLUDE_DIRS}
)
include_directories( ${QT_INCLUDE_DIR} )
set (LIBS ${LIBS} ${Qt5Widgets_LIBRARIES} )
endif()
find_package(Qt5Charts)
if(Qt5Charts_FOUND)
set( QT_INCLUDE_DIR
${Qt5Charts_INCLUDE_DIRS}
)
include_directories( ${QT_INCLUDE_DIR} )
set (LIBS ${LIBS} ${Qt5Charts_LIBRARIES} )
endif()
But the cmake is not been able to find Qt5Charts as it is only available in Qt5.8. The Qt5Widgets is successfully found as it is available in Qt5.5 also.
For Qt5Charts it says
Could not find a package configuration file provided by "Qt5Charts" with any of the following names: Qt5ChartsConfig.cmake qt5charts-config.cmake
Is there a way that I tell cmake to look for packages of Qt5.8 instead of Qt5.5? Or is there a way to specify the default path to look for?
Qt/5.8/gcc_64/lib/cmake is the location of cmakeFiles for 5.8 /usr/lib/x86_64-linux-gnu/cmake for 5.5
回答1:
If you have installed Qt with apt-get or yum or dnf or any other package manager, you need to install Charts separately. I was experiencing the same in Fedora with Qt 5.8. Installation of qt5-qtcharts-devel solved the issue.
sudo dnf install qt5-qtcharts-devel
for debian based distributions and other distributions the package name may be different.
However In my Mac I've installed qt5 using brew there it installed everything including charts.
来源:https://stackoverflow.com/questions/44098195/building-qtcharts-by-using-cmake