0

I am trying to compile a simple program using QT libraries. The problem is that i can't figure out how to use those libraries with CLion. This is my CMakeLists.txt file:

cmake_minimum_required(VERSION 3.3)
project(qt_1)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)

find_package( Qt5Core REQUIRED )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5Gui REQUIRED )

add_executable(qt_1 ${SOURCE_FILES})

qt5_use_modules(qt_1 Core Widgets Gui)

I took this from this post. I also tried multiple examples from various sources but i get the same error.

The error I get when i compile is this:

"C:\Program Files (x86)\JetBrains\CLion 1.2.4\bin\cmake\bin\cmake.exe" --build C:\Users\Andrei\.CLion12\system\cmake\generated\5ef88d9c\5ef88d9c\Debug --  target qt_1 -- -j 8
CMake Error at CMakeLists.txt:8 (find_package):
-- Configuring incomplete, errors occurred!
  By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
See also "C:/Users/Andrei/.CLion12/system/cmake/generated/5ef88d9c/5ef88d9c/Debug/CMakeFiles/CMakeOutput.log".
  asked CMake to find a package configuration file provided by "Qt5Core", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Core" with any
  of the following names:

    Qt5CoreConfig.cmake
    qt5core-config.cmake

  Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set
  "Qt5Core_DIR" to a directory containing one of the above files.  If
  "Qt5Core" provides a separate development package or SDK, be sure it has
  been installed.


mingw32-make.exe: *** [cmake_check_build_system] Error 1
Makefile:175: recipe for target 'cmake_check_build_system' failed

I am running windws 8.1 and i have added the QT bin folder to path.

Update1: The CMakeLists.txt is working fine now, i can include the QT libraries without problem. But now i get this thing when i compile:

undefined reference to `_imp___ZN12QApplicationC1ERiPPci'

Here is my current CMakeLists.txt file:

cmake_minimum_required(VERSION 3.3)
project(qt_1)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_PREFIX_PATH C:/Qt/5.6/msvc2015_64)

set(SOURCE_FILES main.cpp)

find_package( Qt5Core REQUIRED )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5Gui REQUIRED )

add_executable(qt_1 ${SOURCE_FILES})

qt5_use_modules(qt_1 Core Widgets Gui)
Community
  • 1
  • 1
user2997092
  • 63
  • 1
  • 12

0 Answers0