qtcreator 的使用

1、qtcreator 若使用cmake作为编译工具,则cmake默认使用的是ninja作为其generator,若要将ninja改成unix makefile作为cmake的generator,则在这里改:

Tools > Options > Kits > Kit

kits可以翻译为构建套件。

 

2、qtcreator里在cmake的时候打印传给cmake的-Dxxx 变量:

https://stackoverflow.com/questions/13074606/how-do-i-view-the-cmake-command-line-statement-that-qt-creator-executes

 

3、cmake 设置link的时候使用静态库的方法:

https://stackoverflow.com/questions/16991225/cmake-and-static-linking

#Dynamic/Shared Libs
...
#Static start
set_target_properties(icarus PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(icarus PROPERTIES LINK_SEARCH_END_STATIC 1)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
#Static Libs
...
#Set Linker flags
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

 或者这种方法:

https://stackoverflow.com/questions/14077611/how-do-i-tell-cmake-to-link-in-a-static-library-in-the-source-directory/41495207

add_executable(main main.cpp)
target_link_libraries(main ${CMAKE_SOURCE_DIR}/libbingitup.a)

CMake favours passing the full path to link libraries, so assuming libbingitup.a is in ${CMAKE_SOURCE_DIR}

 

4、在command line里手动执行cmake的方式来编译qt项目:

$ mkdir build
$ cmake -DCMAKE_PREFIX_PATH:STRING="/home/hzh/soft/softy/Qt5.14.2/5.14.2/gcc_64" ..
$ make -j4

 

posted @ 2020-07-18 10:23  微信公众号--共鸣圈  阅读(549)  评论(0编辑  收藏  举报