So I've been trying to get my programs with QPrinter to work compile with cmake+mingw+qt5.2 but I'm having issues: the following test program doesn't compile because it cant find QPrinter which should be part of QtCore
#include <QPrinter>
#include <QApplication>
#include <windows.h>
int main()
{
QApplication a( argc, argv );
return 0;
} // end
this is my cmake file
SET(CMAKE_C_COMPILER E:/Qt/Qt5.2.1/Tools/mingw48_32/bin/gcc.exe)
SET(CMAKE_CXX_COMPILER E:/Qt/Qt5.2.1/Tools/mingw48_32/bin/g++.exe)
cmake_minimum_required(VERSION 2.8)
PROJECT (test_prog)
add_definitions(-std=c++11)
SET( test_prog_SRCS test.cpp)
# Tell CMake to run moc when necessary:
set(CMAKE_AUTOMOC ON)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Widgets finds its own dependencies.
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
include_directories(
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Core_INCLUDE_DIRS}
)
add_executable(test_prog WIN32 ${test_prog_SRCS})
target_link_libraries(test_prog ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} )
The Error is:
test.cpp:1:20: fatal error: QPrinter: No such file or directory
#include <QPrinter>
Does anyone know the right incantations to get this to work?
With CMake 2.8.11:
SET(CMAKE_C_COMPILER E:/Qt/Qt5.2.1/Tools/mingw48_32/bin/gcc.exe)
SET(CMAKE_CXX_COMPILER E:/Qt/Qt5.2.1/Tools/mingw48_32/bin/g++.exe)
cmake_minimum_required(VERSION 2.8.11)
PROJECT (test_prog)
add_definitions(-std=c++11)
SET( test_prog_SRCS test.cpp)
# Tell CMake to run moc when necessary:
set(CMAKE_AUTOMOC ON)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5PrintSupport REQUIRED)
add_executable(test_prog WIN32 ${test_prog_SRCS})
target_link_libraries(test_prog Qt5::PrintSupport)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With