李庭競
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    2
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 在Windows上用VS Code搭配cmake + GCC + mingw開發多檔案C++專案 ok好來記錄一下標題打得這麼一長串的東東要怎麼讓它執行起來,相信會google或找到或存到這篇的你應該是會有這個機掰的需求,畢竟這東西當初搞了我整整兩個禮拜,不同電腦狀況又都不一樣QAQ 但撰寫這篇文章時,有重開一個windows sandbox的環境進行全新安裝測試,所以應該會是90%成功的方式了吧! 我的作法有點倒果為因,可能不是正統做法,但我也只是要讓他可以跑起來而已QAQ 專案的CMakeLists.txt為下圖結構 ![](https://i.imgur.com/hLa6CCQ.png) ## 事前準備: [VS code **System Installer** (安裝過程會提醒你要裝對)](https://code.visualstudio.com/#alt-downloads) [正確版本的GCC+mingw](https://sourceforge.net/projects/winlibs-mingw/files/) (codeblocks用的是GCC8.1.0,筆者自己用9.2.0,學長用10.3.0,撰稿當下最新版為12.2.0) (其他參數的判斷請洽下文) [mingw-get-setup](https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/) [CMake GUI](https://cmake.org/download/)非必要,因為功能有包在VS extension,但還是可以裝! :::success 筆者自己有留一份 VS code 1.71.2 + GCC 9.2.0 + mingw 的安裝檔備份,假使哪天這些連結有失效的話,文章最底有相關聯絡資訊 ::: ## 安裝步驟 抓穩囉! ### 1. 先解壓縮指定的GCC+mingw版本到你想要的地址(本文指定在C:\mingw64) 線上安裝檔(mingw-w64-install)理論上不能用(所以我的事前準備也沒有他),而且停在舊版,所以要自己手動下載需要用到的7z ![](https://i.imgur.com/KwEdH9B.png) 這裡要選你要的版本,而筆者的版本在最底部XD ![](https://i.imgur.com/Z9uwVKi.png) 因為9.2.0太乾淨惹(?)所以截了很長的代碼,並提供如下解釋 :::success i686代表為32bit only(無法compile出64bit exe),**x86_64**為32+64bit都有 **posix** vs win32,大致上為多執行續的編譯方式,win32不支援多執行續,所以基本上會裝posix **seh** vs sjlj vs dwarf 在處理exceptions時會用不同的方法return,有點複雜我不是很清楚架構,不過最基礎的是seh,所以我也選用這個版本 ::: ### 2. 將剛剛那個地址及內部的bin加入到PATH ![](https://i.imgur.com/CDOStTJ.png) :::success 打開PATH的方法,左下角開始按右鍵>系統>找到最右邊的進階系統設定>環境變數>path按編輯>key入地址 ::: ### 3. 安裝VS CODE,並安裝以下3個extensions,安裝完成後關閉VS code C/C++, cmake, cmake tools (此步驟截圖略,應該是也不需要啦XD) ### 4. 安裝mingw-get-setup,請以系統管理員身分執行,並指定安裝地址在剛剛的GCC+mingw的解壓縮地址 ![](https://i.imgur.com/tEiDuBQ.png) 請再次確認地址有跟GCC+mingw的解壓縮地址相同 ### 5. 打開MinGW Installation Manager,在all packages裡面找到mingw32-make-bin,安裝他! ![](https://i.imgur.com/QGo2UsV.png) 左邊點選All Packages,右邊開始拉找到mingw32-make-bin ![](https://i.imgur.com/eLag2fv.png) 在回到左上角的installation,選apply changes ### 6. 回到VS code,按下ctrl+shift+P 選擇 C/C++:Edit Configurations(UI) ![](https://i.imgur.com/PPDKQbf.png) ![](https://i.imgur.com/gKrlbTW.png) 這裡請確認有選定到正確的compiler path ### 7. 打開專案檔,點左下角Cmake tools的kit選擇compiler位置,理應自己抓到惹,沒有的話要把第5步解除安裝make-bin後重新安裝! ![](https://i.imgur.com/pe06CAW.png) ### 8. 按run,大功告成,有夠感動痛哭流涕QAQ ![](https://i.imgur.com/VKRaE72.png) 開心灑花,可以到debug console去確認程式的執行狀況囉! ::: danger 如果有人知道怎麼設定這種情況下的breakpoint,霸脫教我QAQ ::: :::warning CopyRight belongs to CrazyRyan庭競,未經許可嚴禁商業轉發,學術用途傳承不在此限 [CrazyRyan庭競 的 Github](https://github.com/CrazyRyan0812/) [CrazyRyan庭競 的 攝影集](https://www.crazyryan.xyz/) :::

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully