MAC M1 开发环境配置

MAC JAVA、C++ 、MySQL开发环境配置

  • JAVA(JDK) & IDEA & MAVEN
    • JDK
    • IDEA
    • MAVEN
  • GIT
  • DOCKER
    • 安装
    • 挂载问题
  • C++ & VsCode
    • C++
    • VsCode
      • Debug
        • 2个软件
        • 5个插件
        • 4个.json
        • 1个.sh
        • 打断点,可以快乐Debug了
  • MySQL & Navicat
    • MySQL
      • 下载安装
      • 忘记密码
    • Navicat
  • Redis
    • Server
    • 客户端工具
  • RabbitMQ
  • 远程终端
    • SecureCRT

我的电脑:MacBook Air (M1, 2020)
点击查看哪些软件已经适配M1芯片

JAVA(JDK) & IDEA & MAVEN

JDK

  1. 下载
    Zulu-JDK1.8.275 迅雷下载
  2. 双击拖拽式安装
  3. 修改环境变量
    命令行:
    vi ./bash_profile 进入编辑
    export JAVA_8_HOME="/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home"
    export JAVA_HOME=$JAVA_8_HOME 修改JAVA_HOME为你的安装路径
    source ./bash_profile 使文件生效
  4. 查看安装是否成功
    java -version 查看当前JDK版本
    在这里插入图片描述

IDEA

IntelliJ IDEA Ultimate 2020.3

IntelliJ IDEA Community 2020.3

MAVEN

IDEA内嵌

GIT

自带git version 2.24.3 (Apple Git-128)

DOCKER

安装

下载并安装桌面版(自带Server)
Docker For Mac 迅雷下载

挂载问题

    1. 创建宿主机目录
      宿主机目录需先手动创建好(存疑,与其他版本不同,挂载时不会自动创建)
    1. 修改Preference
      将宿主机上刚创建的(绝对)目录加入docker的preferences-Resources-FILESHARING 中
      MAC M1 开发环境配置_第1张图片
    1. 挂载
      docker run -v 宿主机绝对目录:容器绝对目录
      宿主机目录会覆盖容器目录(存疑),新建的宿主机目录会把容器中对应目录覆盖成
      建议挂载容器中不存在的目录,即在容器中自动新建目录与宿主机同步;在容器中再配置文件链接;
    1. 修改与同步
      vi、echo等都是双向同步(存疑,与其他版本不同)
      宿主机文件、目录权限可能导致在容器中操作挂载的目录、文件时出现Permission Denied。开放权限即可。
    1. 修改挂载配置
      方法1:提交当前容器为镜像,然后重新挂载运行;
      方法2
      方法3

C++ & VsCode

C++

略。

VsCode

Debug

2个软件

  1. Xcode,没有的话APPStore下载
  2. Vscode,官网Arm版

5个插件

    1. c/c++(搜索安装即可)
    1. Code Runner(搜索安装即可)
    1. CodeLLDB(搜索安装即可)
    1. c++ extension pack(搜索安装即可)
    1. vscode-lldb作者vadimcn提供的 m1 arm版的插件(测试版)
      下载后点击Extensions界面的Install From VSIX,选择即可安装完成。
    1. 不要使用c/c++ clang adapter那个插件。。。已安装的话卸载掉~

4个.json

    1. launch.json调用vscode的Debug功能
{
     
    "version": "0.2.0",
    "configurations": [
        {
     
       //只是个名字
            "name": "(lldb) Launch",
            //固定
            "type": "lldb",
            //固定
            "request": "launch",
            //执行你的代码生成的可执行文件
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
            //参数列表
            "args": [],
            "cwd": "${workspaceFolder}",
            //先通过名为”Build with Clang“的Task(在task.json中定义的名字一致)进行编译
            "preLaunchTask": "Build with Clang"
        }
    ]
}
    1. tasks.json定义编译Task
{
     
    "version": "2.0.0",
    "tasks": [
        {
     
        //Task名
            "label": "Build with Clang",
            //命令类型
            "type": "shell",
            //command和args拼接成完整命令;clang++ xxx.cpp -o xxx.out即将你的cpp文件编译生成.out可执行文件(后缀随意,没有后缀都行)
            "command": "clang++",
            "args": [
                "-std=c++17",
                "-stdlib=libc++",
                "-g",
                "${fileBasenameNoExtension}.cpp",
                "-o",
                "${fileBasenameNoExtension}.out"
            ],
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
     
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
    1. c_cpp_properties.json定义一些路径和全局环境
{
     
    "configurations": [
        {
     
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks",
                "/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include",
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
                "/Library/Developer/CommandLineTools/usr/include"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks",
                "/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include",
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
                "/Library/Developer/CommandLineTools/usr/include"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "macos-clang-x64"
        }
    ],
    "version": 4
}
    1. settings.json对插件等作出设置
{
     
    "C_Cpp.updateChannel": "Insiders",
    "markdown.preview.fontSize": 16,
    "editor.fontSize": 14,
    "debug.onTaskErrors": "showErrors",
    "workbench.colorTheme": "Default Dark+",
    "workbench.preferredDarkColorTheme": "Default Dark+",
    "debug.allowBreakpointsEverywhere": true,
    "explorer.confirmDelete": false,
    "editor.codeActionsOnSave": {
     },
    "code-runner.executorMap": {
     
    //codeRunner插件对于cpp文件run的时候的使用命令
        "cpp": " clang++ $dir$fileName -o $dir$fileNameWithoutExt.out && $dir$fileNameWithoutExt.out",
        "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "php": "php",
        "python": "python -u",
        "perl": "perl",
        "perl6": "perl6",
        "ruby": "ruby",
        "go": "go run",
        "lua": "lua",
        "groovy": "groovy",
        "powershell": "powershell -ExecutionPolicy ByPass -File",
        "bat": "cmd /c",
        "shellscript": "bash",
        "fsharp": "fsi",
        "csharp": "scriptcs",
        "vbscript": "cscript //Nologo",
        "typescript": "ts-node",
        "coffeescript": "coffee",
        "scala": "scala",
        "swift": "swift",
        "julia": "julia",
        "crystal": "crystal",
        "ocaml": "ocaml",
        "r": "Rscript",
        "applescript": "osascript",
        "clojure": "lein exec",
        "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
        "racket": "racket",
        "scheme": "csi -script",
        "ahk": "autohotkey",
        "autoit": "autoit3",
        "dart": "dart",
        "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        "haskell": "runhaskell",
        "nim": "nim compile --verbosity:0 --hints:off --run",
        "lisp": "sbcl --script",
        "kit": "kitc --run",
        "v": "v run",
        "sass": "sass --style expanded",
        "scss": "scss --style expanded",
        "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
        "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "editor.wordWrap": "on",
        "editor.wordWrapColumn": 150,
    },
    //指定lldb插件的shell脚本位置
    "lldb.adapterEnv": {
     
        "LLDB_DEBUGSERVER_PATH": "写你的shell脚本的放置位置"
    }
}

1个.sh

随意命名,随意位置,配合lldb测试版插件生效;内容如下:

arch -arch arm64e /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/debugserver "$@"

打断点,可以快乐Debug了

MySQL & Navicat

MySQL

下载安装

忘记密码

    1. 停止mysql server
      sudo /usr/local/mysql/support-files/mysql.server stop

    1. 免验证模式运行MySQL
      sudo su
      cd /usr/local/mysql/bin
      ./mysqld_safe --skip-grant-tables
      MySQL Server在当前终端显式运行,当前终端无法输入,以下操作需要新开一个终端进行。
    1. 打开新的终端,进入MySQL
      cd /usr/local/mysql/bin
      mysql 无需用户名密码,直接回车即可进入
    1. 修改密码,刷新权限
      alter user'root'@'localhost' identified with mysql_native_password by 'newpassword'; 用你的新密码替换newpassword,无需password()函数;
      flush privileges;
      (原 use mysql;update user set …;set password for …等形式已过期不可用)
    1. 重启服务
      sudo /usr/local/mysql/support-files/mysql.server restart
    1. 检查登录
      mysql -uroot -p

Navicat

Navicat12 下载、安装与激活

Redis

Server

客户端工具

RedisDesktopManager
AnotherRedisDesktopManager

RabbitMQ

远程终端

SecureCRT

SecureCRT+SecureFX

你可能感兴趣的:(工具,mac,m1,配置)