简体   繁体   中英

Setting up Qt for CLion

i am struggling to set up Qt5 for CLion. Somehow, I did this for VS before but failed to do this in CLion. Building and Including Qt headers are fine and CLion find qt symbols and auto-completes them but when i am using an Qt object Clion giving me this error:

C:\\Users\\binhb.CLion2016.1\\system\\cmake\\generated\\LBMTopoOptimization-ae159e87\\ae159e87\\Debug\\LBMTopoOptimization.exe Process finished with exit code -1073741515 (0xC0000135)

My CMake file looks like this:

cmake_minimum_required(VERSION 3.5)
project(LBMTopoOptimization)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

# set prefix path for Qt5
set (CMAKE_PREFIX_PATH "C:\\QT\\5.7\\mingw53_32\\")

# Find QT Libraries
find_package( Qt5Core REQUIRED )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5Gui REQUIRED )

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

set(SOURCE_FILES main.cpp)
add_executable(LBMTopoOptimization ${SOURCE_FILES})

# Use the modules from Qt 5.
target_link_libraries(LBMTopoOptimization Qt5::Widgets Qt5::Core Qt5::Gui)

The error would already occur by using for example a QString:

#include <QWidget>

int main(int argc, char** argv ){
    QString name = "this is a string";
return 0;
}
  • System specification:
  • Windows 10
  • Clion 1.3
  • Qt 5.7
  • CMake 3.6 rc3
  • mingw-gcc 4.9.3

I looking forward for any hints.

Try to add Qt library's installation directory (select specific Qt version and build system \\bin sub-subdirectory) to PATH environment variable .

I have been struggling with similar problem. I have had installed Qt library (version 5.6 and 5.7) in C:\\Qt\\ directory. In my project I use version 5.6. Build system is MinGW.

After I have added C:\\Qt\\5.6\\mingw49_32\\bin , everything works fine.

The reason for this behaviour is quite simple. During the build, build system 'knows' where to search for libraries, but when app is being executed, Windows system searches for required libraries in application's directory and directories specified by PATH variable.

If it fails, application exits with -1073741515 (0xC0000135) error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM