Clion+Cmake+Qt5+Qwt+msys2+MinGW在Windows下的安裝配置使用教程

摘要:

CLion, a cross-platform C/C++ IDE. 本文主要介紹基於Clion做爲IDE, MinGW做爲編譯器,CMake做爲項目構建工具,開發基於Qt五、qwt的C++圖形GUI項目的安裝、配置、編譯過程。php

KeyWords:Clion;Cmake;Qt5;Qwt;msys2;MinGW;Windowspython

目錄:

  1. 軟件安裝
  2. 環境配置
  3. 開發示例
  4. 注意事項
  5. pacman基本命令參數

教程:

1. 軟件安裝

  • Jetbrains CLion
  • Cmake(可選)
    • 除非必要,通常沒必要另安裝,可使用Clion中自帶的Cmake。如必定要選用我的安裝的,請注意在工具鏈中的Cmake路徑設置,不然能夠直接選bundled便可。
  • Qt5 for MinGW64 use msys2
  • msys2:下載安裝msys2,在MinGW-64下載頁面(url: http://mingw-w64.org/doku.php/download ),進入msys2頁面進行下載,也可直接從http://www.msys2.org進入下載( 32位:msys2-i686-20180531.exe;64位:msys2-x86_64-20180531.exe),建議安裝在磁盤空間大的磁盤目錄下,由於安裝Qt及依賴軟件須要佔用不少存儲空間,本例中安裝在C:\msys64目錄下,並將此目錄和bin目錄加入系統路徑中。
    • Pacman:msys2 移植了Arch Linux 上的軟件包管理系統 Pacman,有了包管理系統,升級、安裝新的軟件就很簡單了(pacman經常使用命令參數見文末說明)。在此管理系統中,軟件包的命名中前綴爲「mingw-w64-」,而後是針對命名32位或64位系統使用, "-x86_64-" for 64-bit, "-i686-" for 32-bit。下載的軟件包也會據此安裝部署到不一樣的目錄中,如32位的軟件會部署到C:\msys64\mingw32中,64位的會部署到C:\msys64\mingw64中。軟件下載包是放在C:\msys64\var\cache\pacman\pkg中。
  • Qt5:msys2提供編譯好的MinGW-w64套件,通常提供了32位和64位兩個版本。Qt也分別有編譯好的32位和64位版本,以及靜態連接和動態連接共4個版本,以及QtCreator。(mingw-w64-i686-qt5,mingw-w64-i686-qt5-static,mingw-w64-i686-qt-creator;mingw-w64-x86_64-qt5,mingw-w64-x86_64-qt5-stati, mingw-w64-x86_64-qt-creator)。
    • 啓動msys2的命令行窗口,經過pacman下載安裝MinGW版本的Qt5。在此已32位的爲例。
    • pacman -S mingw-w64-i686-qt5 mingw-w64-i686-qt5-static
    • 下載安裝make和gdb工具;
    • pacman -S mingw-w64-i686-make mingw-w64-i686-gdb
    • 安裝完成後,在系統路徑中添加bin路徑;
    • C:\msys64;C:\msys64\mingw32\bin
    • 至此,便可正常使用Qt5了。能夠用Qt5自帶的示例測試是否安裝正常,用CLion編譯過程附後。
  • 第三方庫安裝(以QWT爲例)
    • QWT:全稱是Qt Widgets for Technical Applications,是一個基於LGPL版權協議的開源項目, 可生成各類統計圖。它爲具備技術專業背景的程序提供GUI組件和一組實用類,其目標是以基於2D方式的窗體部件來顯示數據, 數據源以數值,數組或一組浮點數等方式提供, 輸出方式能夠是Curves(曲線),Slider(滾動條),Dials(圓盤),Compasses(儀表盤)等等。該工具庫基於Qt開發,因此也繼承了Qt的跨平臺特性。在msys2中針對MinGW-w64提供了兩個版本(mingw-w64-i686-qwt-qt5 mingw-w64-x86_64-qwt-qt5)。本文以32位爲例,進行下載安裝。由於第三方庫的路徑都是基於msys2的,因此無需後續系統路徑的配置。
    • pacman -S mingw-w64-i686-qwt-qt5
    • 至此,若是須要用Clion做爲IDE,用MinGW做爲編譯器,用CMake做爲項目構建工具,開發基於Qt五、qwt的C++圖形GUI項目,就已經基本具有條件了。
  • 其餘可選的編譯器或Qt版本
    • 基於MinGW的Qt5官方安裝包模式:此模式下,需用其自帶的MinGW,如使用qwt,需對qwt源碼進行此版本下的編譯生成,方可以使用。
      • 下載地址: http://download.qt.io/archive/qt/5.7/5.7.1/qt-opensource-windows-x86-mingw530-5.7.1.exe
      • 安裝須要注意,選擇Tools裏面的MinGW5.3.0,安裝的Qt for MinGW的Tools中含有gcc/g++,是用來編譯此版本Qt項目的。在CLion中,如圖設置Toolchains:

                       

    • LLVM Clang for MinGW64 (可選)
      • Step 1: Install the msys2.
      • Step 2: Launch the msys terminal and install llvm/clang.
      • pacman -S mingw-w64-i686-llvm mingw-w64-i686-clang mingw-w64-i686-make mingw-w64-i686-gdb
      • Step 3: Let CMake detect clang from the environment variables.
      • CLion Setting Toolchains

 

      • CLion Setting CMake

 

      • Step 4: Rebuild the project workspace.
      • Tools -> CMake -> Reset Cache and Reload Project
"C:\Program Files\JetBrains\CLion 2019.1\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=C:/msys64/mingw32/bin/mingw32-make.exe -DCMAKE_C_COMPILER=C:/msys64/mingw32/bin/clang.exe -DCMAKE_CXX_COMPILER=C:/msys64/mingw32/bin/clang++.exe -G "CodeBlocks - MinGW Makefiles" C:\CLionProjects\DynamicLayouts
-- The C compiler identification is Clang 5.0.1
-- The CXX compiler identification is Clang 5.0.1
-- Check for working C compiler: C:/msys64/mingw32/bin/clang.exe
-- Check for working C compiler: C:/msys64/mingw32/bin/clang.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys64/mingw32/bin/clang++.exe
-- Check for working CXX compiler: C:/msys64/mingw32/bin/clang++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/CLionProjects/DynamicLayouts/cmake-build-release-msys-clang

[Finished]

然而,這種方法編譯Qt項目,生成的項目執行文件比用QtTool的MinGW編譯的大!c++

2. CLion開發Qt5環境配置

  • CLion Setting Toolchains

 

  • CLion Setting CMake(除選擇Build Type和Toolchain外,其餘都是默認項)

 

  • 通常在作了工具鏈修改或項目CMakeLists.txt文件的修改,須要從新構建項目,再進行項目編譯調試。經過在CLion中,選擇Tools -> CMake -> Reset Cache and Reload Project

 

3. 開發示例

  • Qt5 for msys2 MinGW32
  • CMakeLists.txt for qt5 project,在CLion中,可用MinGW3二、MinGW for Qt Tool、Clang編譯工具鏈都可。

 

cmake_minimum_required(VERSION 3.7)
project(DynamicLayouts)
# 指定c++標準的版本
set(CMAKE_CXX_STANDARD 14)

# 設置Qt5的cmake模塊所在目錄,若是不設置將使用系統提供的版本
# QT_DIR和QT_VERSION是指定了qt安裝目錄和版本的環境變量
# set(CMAKE_PREFIX_PATH $ENV{QT_DIR}/$ENV{QT_VERSION}/mingw53_32/lib/cmake)
set(CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.7.1\\5.7\\mingw53_32\\lib\\cmake")

#設置工程包含當前目錄,非必須
set(CMAKE_INCLUDE_CURRENT_DIR ON)

#打開全局moc,設置自動生成moc文件,必定要設置
set(CMAKE_AUTOMOC ON)
#打開全局uic,非必須
set(CMAKE_AUTOUIC ON)
#打開全局rcc,非必須,如需打開,注意修改33行的qrc文件名
set(CMAKE_AUTORCC ON)

# Add compiler flags for building executables (-fPIE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

#設置運行時輸出可執行文件目錄(CMAKE源目錄CMAKE_CURRENT_SOURCE_DIR,執行目錄CMAKE_CURRENT_BINARY_DIR)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
#設置運行時輸出共享庫文件目錄
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)

#查找須要的Qt庫文件,最好每個庫都要寫,Qt也會根據依賴關係自動添加 set(Projects_QT5_COMPONENTS Core Gui Widgets ) set(Projects_QT5_Includes ${Qt5Core_INCLUDE} ${Qt5Gui_INCLUDE} ${Qt5Widgets_INCLUDE} ) set(Projects_QT5_Libraries Qt5::Core Qt5::Gui Qt5::Widgets ) find_package(Qt5 COMPONENTS ${Projects_QT5_COMPONENTS} REQUIRED) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${Projects_QT5_Includes} )#設置項目包含目錄 #查找當前文件夾中的全部源代碼文件,也能夠經過Set命令將全部文件設置爲一個變量 FILE(GLOB SRC_FILES "./*.cpp") #查找設置當前文件夾中全部的頭文件 FILE(GLOB HEAD_FILES "./*.h") #查找設置當前文件夾中全部的ui文件 FILE(GLOB UI_FILES "./*.ui") #經過Ui文件生成對應的頭文件,必定要添加 # qt5_wrap_ui(WRAP_FILES ${UI_FILES}) #添加資源文件,非必須,一旦採用,注意修改相應的qrc文件名 # set(RCC_FILES rcc.qrc) #將ui文件和生成文件整理在一個文件夾中,非必須 # source_group("Ui" FILES ${UI_FILES} ${WRAP_FILES} ) #建立工程文件 # add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES} ${RCC_FILES} ${WRAP_FILES}) add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES} ) #添加Qt5依賴項 target_link_libraries(${PROJECT_NAME} ${Projects_QT5_Libraries} )

 

 

  • CMakeLists.txt for qt5-qwt Projects,在CLion中,用msys2的MinGW32編譯工具鏈。

 

cmake_minimum_required(VERSION 3.7)
project(QwtRadio)
# 指定c++標準的版本
set(CMAKE_CXX_STANDARD 14)

# 設置Qt5的cmake模塊所在目錄,若是不設置將使用系統提供的版本C:\Qt\Qt5.7.1\5.7\mingw53_32\lib\cmake
# QT_DIR和QT_VERSION是指定了qt安裝目錄和版本的環境變量C:\msys64\mingw32\lib\cmake
set(CMAKE_PREFIX_PATH "C:\\msys64\\mingw32\\lib\\cmake")

#設置工程包含當前目錄,非必須
set(CMAKE_INCLUDE_CURRENT_DIR ON)

#打開全局moc,設置自動生成moc文件,必定要設置
set(CMAKE_AUTOMOC ON)
#打開全局uic,非必須
set(CMAKE_AUTOUIC ON)
#打開全局rcc,非必須,如需打開,注意修改33行的qrc文件名
set(CMAKE_AUTORCC ON)

# Add compiler flags for building executables (-fPIE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

#設置運行時輸出可執行文件目錄(CMAKE源目錄CMAKE_CURRENT_SOURCE_DIR,執行目錄CMAKE_CURRENT_BINARY_DIR)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
#設置運行時輸出共享庫文件目錄
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)

#查找須要的Qt庫文件,最好每個庫都要寫,Qt也會根據依賴關係自動添加 MESSAGE("======Searching for Qt5======") set(Projects_QT5_COMPONENTS Core Gui Widgets ) set(Projects_QT5_Includes ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ) set(Projects_QT5_Libraries Qt5::Core Qt5::Gui Qt5::Widgets ) find_package(Qt5 COMPONENTS ${Projects_QT5_COMPONENTS} REQUIRED) MESSAGE(${Qt5Widgets_INCLUDE_DIRS}) MESSAGE(${Projects_QT5_Libraries}) MESSAGE("=======Searching for QWT======") FIND_PATH(QWT_INCLUDE_DIR NAMES qwt.h PATHS ${QT_INCLUDE_DIR} PATH_SUFFIXES qwt ) MESSAGE(${QWT_INCLUDE_DIR}) FIND_LIBRARY(QWT_LIBRARY NAMES qwt PATHS ${QT_INCLUDE_DIR}/lib ) MESSAGE(${QWT_LIBRARY}) #設置項目包含目錄,包括將第三方庫附加 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${Projects_QT5_Includes} ${QWT_INCLUDE_DIR} ) # 將第三方庫附加到變量Projects_Extra_Libraries中,便於管理 list(APPEND Projects_Extra_Libraries ${QWT_LIBRARY}) # 等價於VS下 屬性-<配置屬性-<C/C++-<預處理器,預處理器定義:QWT_DLL LOG4QT_DLL ADD_DEFINITIONS(-DQWT_DLL) #查找當前文件夾中的全部源代碼文件,也能夠經過Set命令將全部文件設置爲一個變量 FILE(GLOB SRC_FILES "./*.cpp") #查找設置當前文件夾中全部的頭文件 FILE(GLOB HEAD_FILES "./*.h") #查找設置當前文件夾中全部的ui文件 FILE(GLOB UI_FILES "./*.ui") #經過Ui文件生成對應的頭文件,必定要添加 # qt5_wrap_ui(WRAP_FILES ${UI_FILES}) #添加資源文件,非必須,一旦採用,注意修改相應的qrc文件名 # set(RCC_FILES rcc.qrc) #將ui文件和生成文件整理在一個文件夾中,非必須 # source_group("Ui" FILES ${UI_FILES} ${WRAP_FILES} ) #建立工程文件 # add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES} ${RCC_FILES} ${WRAP_FILES}) add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES} # ${RCC_FILES} ) #添加Qt5依賴項,添加qwt等第三方依賴項 target_link_libraries(${PROJECT_NAME} ${Projects_QT5_Libraries} ${Projects_Extra_Libraries} )

 

 

  • CMake輸出信息:

 

"C:\Program Files\JetBrains\CLion 2019.1\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=C:/msys64/mingw32/bin/mingw32-make.exe -DCMAKE_C_COMPILER=C:/msys64/mingw32/bin/gcc.exe -DCMAKE_CXX_COMPILER=C:/msys64/mingw32/bin/g++.exe -G "CodeBlocks - MinGW Makefiles" C:\CLionProjects\QwtRadio
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: C:/msys64/mingw32/bin/gcc.exe
-- Check for working C compiler: C:/msys64/mingw32/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys64/mingw32/bin/g++.exe
-- Check for working CXX compiler: C:/msys64/mingw32/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
======Searching for Qt5======
C:/msys64/mingw32/include/C:/msys64/mingw32/include/QtWidgetsC:/msys64/mingw32/include/QtGuiC:/msys64/mingw32/include/QtCoreC:/msys64/mingw32/share/qt5//mkspecs/win32-g++
Qt5::CoreQt5::GuiQt5::Widgets
=======Searching for QWT======
C:/msys64/mingw32/include/qwt
C:/msys64/mingw32/lib/libqwt.dll.a
-- Configuring done
-- Generating done
-- Build files have been written to: C:/CLionProjects/QwtRadio/cmake-build-release-mingw32msys

[Finished]

 

 

  • 示例用QWT自帶的示例Radio(可從https://sourceforge.net/projects/qwt/files/qwt/下載的壓縮包中得到),在項目中去掉.pro文件,而後添加相應針對qwt的CMakeLists.txt文件,在CLion中,用基於msys2的工具鏈進行編譯調試,順利成功!

 

注意事項

  • 在測試過程當中發現,必定要注意非自編譯的庫,如Qt、Qwt等,都是從官方或msys中得到,必需要保證其已編譯的庫所使用的工具環境一致性,不一樣工具環境編譯的庫是不能互相調用的。如須要使用msys中的qwt庫,就必定要用其對應的Qt庫(一樣從msys中得到的),由於都是用msys中的MinGW生成的,因此在使用時不會有問題;若是用Qt官方的MinGW版本的Qt進行使用,則不能成功,即便編譯經過,會輸出:Process finished with exit code -1073741511 (0xC0000139),打開執行文件會提示沒法定位程序入口的彈窗,如必須使用此版本Qt,那須要經過qwt源碼,用此Qt版本工具中的MinGW從新編譯生成qwt庫,再行使用方可。同時,這也體如今CLion的Toolchains設置中,各項也都應保持一致。 

 


 

附:pacman基本命令參數

 

更新本地軟件包:
pacman -S --refresh
能夠縮寫爲:pacman -Sy

升級軟件包:
pacman -S --refresh --sysupgrade 
能夠縮寫爲:pacman -Syu

列出全部已安裝軟件包:
pacman -Q --explicit
或者
pacman -Q -e
能夠列出全部的軟件組:
pacman -Q --groups

安裝新的軟件包:
pacman -S <package_names|package_groups>
好比安裝 Qt5:
pacman -S mingw-w64-i686-qt5 
注:能夠不用明確軟件包版本,系統會根據依賴項進行自動匹配下載相應版本。

搜索軟件包:
若是不清楚軟件的準確名稱,能夠經過核心軟件名查詢軟件包的名稱。
pacman -Ss <name_pattern>
好比搜索gcc相關的軟件
pacman -Ss gcc

刪除軟件包:
pacman -R <package_names|package_groups>
  •  MSYS2 pacman mirrors(/msys64/etc/pacman.d)
## mirrorlist.mingw32
## 32-bit Mingw-w64 repository mirrorlist
##

## Primary
## msys2.org
Server = http://mirrors.ustc.edu.cn/msys2/mingw/i686/
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686/
Server = https://mirrors.huaweicloud.com/msys2/mingw/i686/

Server = http://repo.msys2.org/mingw/i686/
Server = https://sourceforge.net/projects/msys2/files/REPOS/MINGW/i686/
Server = http://www2.futureware.at/~nickoe/msys2-mirror/mingw/i686/
Server = https://mirror.yandex.ru/mirrors/msys2/mingw/i686/

--------------------------------------------------------------------------
## mirrorlist.mingw64
## 64-bit Mingw-w64 repository mirrorlist
##

## Primary
## msys2.org
Server = http://mirrors.ustc.edu.cn/msys2/mingw/x86_64/
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64/
Server = https://mirrors.huaweicloud.com/msys2/mingw/x86_64/

Server = http://repo.msys2.org/mingw/x86_64/
Server = https://sourceforge.net/projects/msys2/files/REPOS/MINGW/x86_64/
Server = http://www2.futureware.at/~nickoe/msys2-mirror/mingw/x86_64/
Server = https://mirror.yandex.ru/mirrors/msys2/mingw/x86_64/

 


開發環境安裝配置示例:git

https://www.devdungeon.com/content/install-gcc-compiler-windows-msys2-ccsql

  • Install gcc compiler on Windows with MSYS2 for C/C++

 

  • Installing and running MSYS2

 

Download MSYS2 from http://www.msys2.org/. Download the .exe file and follow the installation instructions on the site. After installing, navigate to the directory where it was installed, and run msys2.exe. For this tutorial, we will assume the default location of C:\msys64. After opening it you should find yourself in a bash shell.shell

 

  • Updating MSYS2

 

MSYS2 uses the pacman package manager that the Arch Linux distribution uses. After your initial install it is a good idea to update all the packages. Update everything using:json

pacman –Syu
pacman –Su
  • Installing gcc using MSYS2

In the MSYS2 bash shell, use pacman again to install the build toolchain and compilers. Run the command below to install the mingw-w64-x86_64-toolchain package group.vim

 

# Install make, autoconf, etc to C:\msys64\usr\bin
pacman -S base-devel

 

# pacman -S base-devel
   1) asciidoc  2) autoconf  3) autoconf2.13  4) autogen  5) automake-wrapper
   6) automake1.10  7) automake1.11  8) automake1.12  9) automake1.13
   10) automake1.14  11) automake1.15  12) automake1.16  13) automake1.6
   14) automake1.7  15) automake1.8  16) automake1.9  17) bison  18) diffstat
   19) diffutils  20) dos2unix  21) file  22) flex  23) gawk  24) gdb
   25) gettext  26) gettext-devel  27) gperf  28) grep  29) groff  30) help2man
   31) intltool  32) lemon  33) libtool  34) libunrar  35) libunrar-devel
   36) m4  37) make  38) man-db  39) pacman  40) pactoys-git  41) patch
   42) patchutils  43) perl  44) pkg-config  45) pkgfile  46) quilt  47) rcs
   48) scons  49) sed  50) swig  51) texinfo  52) texinfo-tex  53) ttyrec
  • Installing other packages with pacman

If you want to compile an SSL program that links to libssl and libcrypto with -lssl -lcrypto you will need to install openssl-devel as shown below. There are many other devel packages. For example, libbz2-devel, libelf-devel, libunrar-devel, and libyaml-devel. The environment is rather limited, but it can be useful for learning.windows

 

# Install all *-devel packages
pacman -S development

 

Packages included in "development" group:數組

:: There are 78 members in group development:
:: Repository msys
   1) apr-devel  2) apr-util-devel  3) aspell-devel  4) bash-devel  5) cloog-devel
   6) gamin-devel  7) gettext-devel  8) glib2-devel  9) gmp-devel  10) heimdal-devel
   11) icu-devel  12) isl-devel  13) jansson-devel  14) jsoncpp-devel  15) libarchive-devel
   16) libargp-devel  17) libassuan-devel  18) libatomic_ops-devel  19) libbobcat-devel
   20) libbz2-devel  21) libcares-devel  22) libcrypt-devel  23) libcurl-devel  24) libdb-devel
   25) libedit-devel  26) libelf-devel  27) libevent-devel  28) libexpat-devel  29) libffi-devel
   30) libgc-devel  31) libgcrypt-devel  32) libgdbm-devel  33) libgnutls-devel
   34) libgpg-error-devel  35) libgpgme-devel  36) libgpgme-python2  37) libgpgme-python3
   38) libguile-devel  39) libiconv-devel  40) libidn-devel  41) libidn2-devel  42) libksba-devel
   43) liblz4-devel  44) liblzma-devel  45) liblzo2-devel  46) libmetalink-devel
   47) libneon-devel  48) libnettle-devel  49) libnghttp2-devel  50) libnpth-devel
   51) libp11-kit-devel  52) libpipeline-devel  53) libpsl-devel  54) libreadline-devel
   55) librhash-devel  56) libsasl-devel  57) libserf-devel  58) libsqlite-devel
   59) libssh2-devel  60) libtasn1-devel  61) libtirpc-devel  62) libtre-devel-git
   63) libunistring-devel  64) libuv-devel  65) libxml2-devel  66) libxslt-devel
   67) libyaml-devel  68) mpc-devel  69) mpfr-devel  70) ncurses-devel  71) openssl-devel
   72) pcre-devel  73) pcre2-devel  74) protobuf-devel  75) ucl-devel  76) util-macros
   77) xproto  78) zlib-devel
  • Optional: Add executables to your Windows PATH

If you want to access everything from your Windows Command Prompt, then add the bin directory to your Windows PATH environment variable. Keep in mind this adds a lot of executables to your path which might conflict with other applications. The usr\bin\ directory contains the whole slew of executables listed above. There is a lot of unnecessary stuff in that directory. mingw64\bin\ directory :

 

;C:\msys64;C:\msys64\mingw64\bin;C:\msys64\usr\bin
  • Header files and libraries

Libraries and include files can be found in two places.

 

# The dynamic lib runtime .dll files will be in bin dirs
# Add the bin directory to PATH environment variable so it can find the .dll files
C:\msys64\mingw64\bin
C:\msys64\usr\bin

# Static libraries
C:\msys64\usr\lib
C:\msys64\mingw64\lib

# Header files
C:\msys64\usr\include
C:\msys64\mingw64\include
  • A note about msys vs mingw64 repos

Some things are only available in the msys/ repo like vim and git, and will only be available in \usr\bin\. Some things like gcc are available in msys\, mingw32\, and mingw64\ repos and can potentially end up being installed in both \usr\bin\ and \mingw64\bin\. This is where you have to be careful about how you set up your PATH environment variable. If you add \usr\bin\ in order to make vim or git available, you will also add everything in that directory, which may conflict with something if you also add the \mingw64\bin\ directory to your path. If you only want the toolchain without as much extra stuff, use the mingw64 packages. Then you can add only the \mingw64\bin directory to your PATH if desired. The mingw64 repository generally has more libraries available for install that are unavailable in the general msys repo (e.g. SDL, exif, freeglut). The msys packages are intended to be used inside the msys shell, and the mingw packages are intended to be used outside of msys2.

 

# Install gcc in C:\msys64\mingw64\bin\ directory
# To go with C:\msys64\mingw64\include and C:\msys64\mingw64\lib
pacman -S mingw-w64-x86_64-toolchain

Packages (17) 
mingw-w64-x86_64-binutils-2.30-5
mingw-w64-x86_64-crt-git-7.0.0.5245.edf66197-1
mingw-w64-x86_64-gcc-8.2.0-3
mingw-w64-x86_64-gcc-ada-8.2.0-3
mingw-w64-x86_64-gcc-fortran-8.2.0-3
mingw-w64-x86_64-gcc-libgfortran-8.2.0-3
mingw-w64-x86_64-gcc-libs-8.2.0-3
mingw-w64-x86_64-gcc-objc-8.2.0-3
mingw-w64-x86_64-gdb-8.2-1
mingw-w64-x86_64-headers-git-7.0.0.5245.edf66197-1
mingw-w64-x86_64-libmangle-git-7.0.0.5230.69c8fad6-1
mingw-w64-x86_64-libwinpthread-git-7.0.0.5231.7da6518b-1
mingw-w64-x86_64-make-4.2.1-2
mingw-w64-x86_64-pkg-config-0.29.2-1
mingw-w64-x86_64-tools-git-7.0.0.5242.1b29d1bc-1
mingw-w64-x86_64-winpthreads-git-7.0.0.5231.7da6518b-1
mingw-w64-x86_64-winstorecompat-git-7.0.0.5230.69c8fad6-1

 

Configuring IDE  to work with this toolchain.

相關文章
相關標籤/搜索