macOS常用配置實錄(vscode等)


記錄一下常用軟件的下載使用以及常見問題

以下軟件的安裝使用全部基於macOS BigSur 11.3.1,M1芯片

微信

目前App Store里的微信3.1.5版本還是intel的

有網友說Rosetta 2運行的微信占用內存很大,不過親測下來CPU和內存的占用都很正常,使用也很流暢

但就是微信的聊天記錄遷移功能着實很詭異

從手機遷移的記錄並沒有出現在列表里,單個聯系人窗口點開之后查詢記錄也是沒有結果

唯一證明它遷移過了的證據是在“從電腦遷移到手機里”有遷移過來的聊天的 圖標顯示

傳輸記錄如上圖,當然最后聊天記錄和文件還是沒傳過來

唯一遷移成功的經歷是在登錄時勾上“同步最近的聊天記錄” [攤手]

真的是不比不知道,同步遷移功能可以做的多糟糕 

壓縮軟件-Keka

UI做的挺好看的

支持以下類型文件

官網下載鏈接是https://www.keka.io/en/

首次使用需要開啟訪問文件夾的權限

Adobe全家桶系列

推薦在Adobe Creative Cloud里下載安裝

鏈接是 https://www.adobe.com/cn/products/catalog.html

Adobe全家桶如何破解

Adobe Zii 官方網站 https://www.adobezii.com/home/ 

使用的時候要注意參考幫助文檔

建議將Adobe用於商業用途的同學購買正版

Office全家桶系列

Office 365是按年訂閱的,Office 2019/2016是買斷制的

如果需要破解,需要下載安裝Office 2019/2016版本

Office全家桶如何激活

一般來說各個大學都會提供Office的激活方式

一般是一個dmg包,安裝即可

配置vscode的c++環境

以前記過一個Mac配置gdb的一些問題

再詳細地記一次吧emm

首先在vsc的擴展商店里下載微軟的"C/C++"擴展 可以看到它是c++擴展里邊熱度最高的

不過單獨安裝這個擴展既不能夠編譯運行也不能夠調試程序,它的作用主要是代碼高亮、代碼補全、代碼改進建議等

然后我們來看到官方的幫助文檔 C/C++ for Visual Studio Code 

macOS自帶clang這個編譯器,在vsc里按下 ⌃` 打開終端,輸入以下命令檢查一下編譯器的配置

首次操作的話會提醒下載命令行開發者工具,同意即可

clang --version

如果在輸出里邊沒有版本號或者顯示clang is not a recognized command的話,你需要把PATH路徑改成編譯器它所在的位置(不過正常情況下是不會有問題的)

接下來是clang的具體配置,轉到clang的官方幫助文檔 Using Clang in Visual Studio Code 

需要說明的一點是,vscode編譯、運行的配置並不是全局的,而是在一個文件夾.vscode里的以下三個文件。這個.vscode文件夾內的配置文件在不同的工作區(你寫程序的文件夾)里是可以不同的,且都需要你自己配置。換句話說它並不是一次配置好了以后,就可以編譯運行在任何地方的.cpp文件。

  • tasks.json (compiler build settings)
  • launch.json (debugger settings)
  • c_cpp_properties.json (compiler path and IntelliSense settings)

按着幫助文檔一步步來,首先選定一個文件夾作為工作區,然后新建一個helloworld.cpp,輸入以下代碼

 1 #include <iostream>
 2 #include <vector>
 3 #include <string>
 4 
 5 using namespace std;
 6 
 7 int main()
 8 {
 9     vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
10 
11     for (const string& word : msg)
12     {
13         cout << word << " ";
14     }
15     cout << endl;
16 }

接下來需要配置 tasks.json 文件

在“終端”欄內選擇 Configure Default Build Task ,再選擇 clang++生成活動文件

上圖:選Configure Default Build Task
上圖:C/C++:clang++ 生成活動文件

然后把tasks.json的內容換成以下代碼

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "type": "shell",
      "label": "clang++ build active file",
      "command": "/usr/bin/clang++",
      "args": [
        "-std=c++17",
        "-stdlib=libc++",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}/${fileBasenameNoExtension}"
      ],
      "options": {
        "cwd": "${workspaceFolder}"
      },
      "problemMatcher": ["$gcc"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

現在就完成了build的配置

接下去是Running the build的環節

回到helloworld.cpp,按⇧⌘B編譯它

結果如上圖就說明正常地完成了編譯,按任意鍵退出

要運行這個程序,可以在終端輸入 ./helloworld

最后是debug的配置 

 

在“運行”欄里選擇 Add Configuration 並依次選擇C++ (GDB/LLDB) 和 clang++ 來新建launch.json文件

這里launch.json的配置就不需要再更改了

再次返回到helloworld.cpp,設置斷點,按下Fn+F5,你會發現程序暫停了一段時間以后什么事情都沒干就退出了

找到了一個stackflow上的帖子提到類似的問題 VS Code debug Rust program: process exited with status -1 (Error 1) on Mac M1 ,另外github上似乎還沒有人提到類似的問題

按照上述這篇帖子的意思,在terminal里斷點調試是沒有問題的,不過在VSC里就somehow不行 [攤手]

github上的其他Unexpected LLDB output from command "-exec-run"的問題及解決方案供參考 [macOS Catalina] Unable to debug with 'externalConsole'  

總的來說這樣配置下來就能夠正常使用c++了 大不了輸出調試嘛

如何添加bits萬能頭?

參考 如何在MAC OS中的VSCODE下添加bits/stdc++.h 

在/Library/Developer/CommandLineTools/usr/include下創建bits文件夾,然后新建stdc++.h文件為以下內容

用命令行操作的話,是先 cd /Library/Developer/CommandLineTools/usr/include,再sudo mkdir bits並輸入密碼,接着cd bits

然后sudo touch stdc++.h,最后open stdc++.h,復制進以下內容,注意保存的時候也要sudo

  1 // C++ includes used for precompiling -*- C++ -*-
  2 
  3 // Copyright (C) 2003-2014 Free Software Foundation, Inc.
  4 //
  5 // This file is part of the GNU ISO C++ Library.  This library is free
  6 // software; you can redistribute it and/or modify it under the
  7 // terms of the GNU General Public License as published by the
  8 // Free Software Foundation; either version 3, or (at your option)
  9 // any later version.
 10 
 11 // This library is distributed in the hope that it will be useful,
 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14 // GNU General Public License for more details.
 15 
 16 // Under Section 7 of GPL version 3, you are granted additional
 17 // permissions described in the GCC Runtime Library Exception, version
 18 // 3.1, as published by the Free Software Foundation.
 19 
 20 // You should have received a copy of the GNU General Public License and
 21 // a copy of the GCC Runtime Library Exception along with this program;
 22 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 23 // <http://www.gnu.org/licenses/>.
 24 
 25 /** @file stdc++.h
 26  *  This is an implementation file for a precompiled header.
 27  */
 28 
 29 // 17.4.1.2 Headers
 30 
 31 // C
 32 #ifndef _GLIBCXX_NO_ASSERT
 33 #include <cassert>
 34 #endif
 35 #include <cctype>
 36 #include <cerrno>
 37 #include <cfloat>
 38 #include <ciso646>
 39 #include <climits>
 40 #include <clocale>
 41 #include <cmath>
 42 #include <csetjmp>
 43 #include <csignal>
 44 #include <cstdarg>
 45 #include <cstddef>
 46 #include <cstdio>
 47 #include <cstdlib>
 48 #include <cstring>
 49 #include <ctime>
 50 
 51 #if __cplusplus >= 201103L
 52 #include <ccomplex>
 53 #include <cfenv>
 54 #include <cinttypes>
 55 #include <cstdbool>
 56 #include <cstdint>
 57 #include <ctgmath>
 58 #include <cwchar>
 59 #include <cwctype>
 60 #endif
 61 
 62 // C++
 63 #include <algorithm>
 64 #include <bitset>
 65 #include <complex>
 66 #include <deque>
 67 #include <exception>
 68 #include <fstream>
 69 #include <functional>
 70 #include <iomanip>
 71 #include <ios>
 72 #include <iosfwd>
 73 #include <iostream>
 74 #include <istream>
 75 #include <iterator>
 76 #include <limits>
 77 #include <list>
 78 #include <locale>
 79 #include <map>
 80 #include <memory>
 81 #include <new>
 82 #include <numeric>
 83 #include <ostream>
 84 #include <queue>
 85 #include <set>
 86 #include <sstream>
 87 #include <stack>
 88 #include <stdexcept>
 89 #include <streambuf>
 90 #include <string>
 91 #include <typeinfo>
 92 #include <utility>
 93 #include <valarray>
 94 #include <vector>
 95 
 96 #if __cplusplus >= 201103L
 97 #include <array>
 98 #include <atomic>
 99 #include <chrono>
100 #include <condition_variable>
101 #include <forward_list>
102 #include <future>
103 #include <initializer_list>
104 #include <mutex>
105 #include <random>
106 #include <ratio>
107 #include <regex>
108 #include <scoped_allocator>
109 #include <system_error>
110 #include <thread>
111 #include <tuple>
112 #include <typeindex>
113 #include <type_traits>
114 #include <unordered_map>
115 #include <unordered_set>
116 #endif

ok這樣就實現了vscode c++的配置啦(整體來說

然后就是按照個人taste對快捷鍵、主題顏色等配置的修改

Brew

brew是macOS/Linux上的一個程序包管理器,可以很方便地下載/管理眾多程序包(原文是"the stuff you need")

官網這邊移步brew.sh

在終端中輸入 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 以下載安裝

期間可能會要求輸入幾次密碼,另外還有概率多次中斷,所以要做好下載持久戰的准備

眾所周知github處於半牆狀態,所以建議找一個網絡帶寬充足的時間/空間並且多嘗試幾次下載(比如說早八時候的寢室)

配置vscode的python環境

鴿了好久的python配置

參考vscode官網的幫助文檔 Getting Started with Python in VS Code

首先和C++的配置一樣,你需要在vsc的擴展商店中下載安裝由Microsoft發布的Python插件(依然是下載量最大的那個)

接下來按下組合鍵Cmd+Shift+P輸入shell command並點擊“在path中安裝‘code’命令”

上圖:把vscode添加到系統路徑

下一步,在如上一條所述下載安裝好brew后,在終端中輸入命令 brew install python3

這一步是在下載python的解釋器

再回到vscode,注意一下左下角圖標

如果出現上圖情況,點一下黃色三角,在彈出的窗口中選擇python3

 

左下角圖標如下圖顯示說明解釋器配置完成了

 

 

 

END


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM