为CLion设置Qt [英] Setting up Qt for CLion

查看:274
本文介绍了为CLion设置Qt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力为CLion设置Qt5。不知何故,我之前为VS做过此操作,但在CLion中却没有做到。构建并包含Qt标头很好,CLion查找qt符号并自动完成它们,但是当我使用Qt对象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\系统\cmake\生成\LBMTopoOptimization-ae159e87\ae159e87\Debug\LBMTopoOptimization.exe
进程结束,退出代码为-1073741515(0xC0000135)

我的CMake文件如下:

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)

使用例如QString可能已发生错误:

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;
}




  • 系统规格:

  • Windows 10

  • Clion 1.3

  • Qt 5.7

  • CMake 3.6 rc3

  • mingw-gcc 4.9.3

    • System specification:
    • Windows 10
    • Clion 1.3
    • Qt 5.7
    • CMake 3.6 rc3
    • mingw-gcc 4.9.3
    • 我期待任何提示。

      推荐答案

      尝试添加Qt库的安装目录(选择特定的Qt版本并构建系统 \bin 子子目录)到 PATH 环境变量。

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

      我一直在努力解决类似的问题。我已经在 C:\Qt\ 目录中安装了Qt库(版本5.6和5.7)。在我的项目中,我使用5.6版。构建系统是MinGW。

      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.

      添加 C:\Qt\5.6\mingw49_32\bin 后,一切正常

      这种行为的原因很简单。在构建过程中,构建系统知道要在哪里搜索库,但是在执行应用程序时,Windows系统会在应用程序的目录以及PATH变量指定的目录中搜索所需的库。

      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.

      如果失败,则应用程序退出并显示-1073741515(0xC0000135)错误。

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

      这篇关于为CLion设置Qt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆