*nux发行版

Msys2

  1. 输入 pacman -Ss gcc,找到mingw-w64-x86_64,选取内容单击右键复制
  2. pacman -S mingw-w64-x86_64-gcc
  3. pacman -S mingw-w64-x86_64-gdb
  4. 安装llvm过程类似

镜像源:
http://mirrors.ustc.edu.cn/
https://mirrors.tuna.tsinghua.edu.cn/
http://mirror.bit.edu.cn/

Ubuntu

stty erase ^H
修改apt源:

  1. sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  2. sudo sed -i -e 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' -e 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
  3. sudo cp /etc/apt/sources.list.bak /etc/apt/sources.list
  4. sudo apt install clang lldb lld clang-tools clangd
  5. sudo apt install libc++-dev libc++abi-dev
  6. sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-9 100
  7. sudo apt install mysql-server
  8. sudo usermod -d /var/lib/mysql/ mysql
  9. sudo mysql_secure_installation
  10. apt autoremove --purge //删除软件包

Fedora

添加软件源:(https://developer.aliyun.com/article/746822

  1. sudo mv /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora.repo.backup
  2. sudo mv /etc/yum.repos.d/fedora-updates.repo /etc/yum.repos.d/fedora-updates.repo.backup
  3. sudo wget -O /etc/yum.repos.d/fedora.repo http://mirrors.aliyun.com/repo/fedora.repo
  4. sudo wget -O /etc/yum.repos.d/fedora-updates.repo http://mirrors.aliyun.com/repo/fedora-updates.repo
  5. sudo dnf clean all && sudo dnf makecache

安装常用软件:

  1. sudo dnf install cmake clang lld git clang-tools-extra

卸载软件的办法:

  1. sudo dnf autoremove 包名

Darwin(MacOS)

Macports清理垃圾:

  1. port clean --all all
  2. port -f uninstall inactive

递归卸载依赖包:

  1. port uninstall --follow-dependencies <portname>

macports沙盒化方法:macports.conf里的sandbox_enable

WSL

安装wsl2的方法:https://docs.microsoft.com/en-us/windows/wsl/install-win10
下载各种distro:https://docs.microsoft.com/en-us/windows/wsl/install-manual
要自动挂载外置硬盘,首先在/etc/wsl.conf中启用mountFsTab,然后在/etc/fstab中添加D: /mnt/d drvfs {options} 0 0,其中的options可以在/etc/wsl.conf里找到,不带任何引号或括号,最后sudo mkdir /mnt/d
使systemctl可用:https://github.com/arkane-systems/genie

设置代理

cat /etc/resolv.conf查看DNS的IP,这就是Windows主机的IP。然后在Windows中关闭防火墙,在clash中打开allow LAN。

各种CLI工具

Docker

安装方法

在docker的registry mirrors里添加https://registry.docker-cn.com 这个镜像站

CMake

set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) 产生clangd需要的文件

参考

罗斯的教程
PILOT Engine
tev
KlayGE

添加依赖:

  1. FIND_PACKAGE(OpenMP REQUIRED)
  2. target_link_libraries(可执行文件名 PRIVATE OpenMP::OpenMP_CXX)
  3. #库很多的时候
  4. #set(LIBS lib1 lib2 lib3 ... libN)
  5. #target_link_libraries(MyExe1 PRIVATE ${LIBS})
  6. #target_link_libraries(MyExe2 PRIVATE ${LIBS})

把外部库引入时,如果不是自己拷贝而是使用vcpkg,使用find_package()和target_link_libraries()即可,其余选项的区别如下:

INCLUDE_DIRECTORIES(添加头文件目录) 它相当于g++选项中的-I参数的作用,也相当于环境变量中增加路径到CPLUS_INCLUDE_PATH变量的作用(这里特指c++。c和Java中用法类似)。

比如: include_directories(“/opt/MATLAB/R2012a/extern/include”)

export CPLUS_INCLUDE_PATH=CPLUS_INCLUDE_PATH:$MATLAB/extern/include

LINK_DIRECTORIES(添加需要链接的库文件目录) 语法: link_directories(directory1 directory2 …)

它相当于g++命令的-L选项的作用,也相当于环境变量中增加LD_LIBRARY_PATH的路径的作用。

比如: LINK_DIRECTORIES(“/opt/MATLAB/R2012a/bin/glnxa64”)

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MATLAB/bin/glnxa64

LINK_LIBRARIES(添加需要链接的库文件路径,注意这里是全路径)

比如: LINK_LIBRARIES(“/opt/MATLAB/R2012a/bin/glnxa64/libeng.so”)

TARGET_LINK_LIBRARIES (设置要链接的库文件的名称) 语法:TARGET_LINK_LIBRARIES(targetlibrary1 library2 ..)

比如(以下写法(包括备注中的)都可以): TARGET_LINK_LIBRARIES(myProject hello),连接libhello.so库 TARGET_LINK_LIBRARIES(myProject libhello.a) TARGET_LINK_LIBRARIES(myProject libhello.so) TARGET_LINK_LIBRARIES(myProject -lhello) ———————————————— 原文链接:https://blog.csdn.net/arackethis/article/details/43488177

使用GLOB语法:

  1. file(GLOB MY_FILES "*.txt")
  2. file(COPY ${MY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

在C++内获得文件路径:

  1. set(PILOT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")

上面的代码会生成一个名叫PILOT_ROOT_DIR的宏,编译时就会变成对应路径的字符串字面量。

Python

virtualenv导出配置方法:https://medium.com/wealthy-bytes/the-easiest-way-to-use-a-python-virtual-environment-with-git-401e07c39cd
递归卸载pip包:

  1. pip3 install pip-autoremove
  2. pip-autoremove somepackage -y

Git

设置和取消代理

  1. git config --global http.proxy http://ip:port
  2. #git config --global https.proxy http://ip:port
  3. #git config --global --unset http.proxy

设置邮箱

  1. git config --global user.name "Cook21"
  2. git config --global user.email "null"

推送到远程仓库

  1. git remote add origin https://github.com/Cook21/xxxxx.git
  2. git branch -M main
  3. git push -u origin main

从远程仓库下载

  1. git clone https://github.com/Cook21/xxxxx.git

想fork但是不想设置成public

  1. 创建一个私有repo
  2. git clone <private-repo>
  3. git remote add upstream <prublic-repo>
  4. git pull upstream main

    .gitignore

    ```cmake
  • 先忽略一切

    !*/ #不忽略文件夹本身

    接下来就是不忽略的文件

    !.hpp !.cpp

Xcode specific

!*/.xcodeproj/* xcuserdata/

/.xcodeproj/project.xcworkspace/ !/*.xcodeproj/project.xcworkspace/xcshareddata

/.xcodeproj/project.xcworkspace/xcshareddata/ !/*.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

/.playground/playground.xcworkspace/ !/*.playground/playground.xcworkspace/xcshareddata

/.playground/playground.xcworkspace/xcshareddata/ !/*.playground/playground.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings ```

各种SQLDB

https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-database