Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
443 views
in Technique[技术] by (71.8m points)

c++ - 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:Usersinhb.CLion2016.1systemcmakegeneratedLBMTopoOptimization-ae159e87ae159e87DebugLBMTopoOptimization.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try to add Qt library's installation directory (select specific Qt version and build system in 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:Qt5.6mingw49_32in, 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...