9. Develop Environment

9.1. Centos7

9.1.1. How to install higher version gcc on centos7 docker?

Ref: https://stackoverflow.com/questions/67090507/how-to-install-gcc-g-9-on-centos-7-docker-centos7

FROM centos:7 AS env

RUN yum update -y && \
    yum install -y centos-release-scl && \
    yum install -y devtoolset-9 && \
    echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc

9.2. CMAKE

9.2.1. cudatoolkit version and supported gpus

9.2.2. How to get the version of library found by CMake?

Ref: https://stackoverflow.com/questions/34138886/how-to-know-version-of-library-found-by-cmake

<package>_VERSION

9.2.3. How to build x86 or x64 on Windows from command line with CMAKE?

Ref: https://stackoverflow.com/questions/28350214/how-to-build-x86-and-or-x64-on-windows-from-command-line-with-cmake

cmake -G "Visual Studio 17 2022" -A Win32 -S .. -B "build32"
cmake -G "Visual Studio 17 2022" -A x64 -S .. -B "build64"
cmake --build build32 --config Release
cmake --build build64 --config Release

For simplicity, only build 64bit version:

cmake .. -A x64
cmake --build . --config Release

9.2.4. ld: warning: missing .note.GNU-stack section implies executable stack

This is a new warning message introduced by GNU bin-utils version 2.39.

出现“ld missing .note.GNU-stack section implies executable stack”的错误提示, 通常是因为在链接过程中,某些对象文件缺少.note.GNU-stack节,导致链接器默认认为可能需要一个可执行的栈。 这在现代操作系统中是不推荐的做法,因为可执行的栈可能会导致安全问题,如缓冲区溢出攻击。

需要在汇编码中加入:

.section    .note.GNU-stack,"",@progbits

或者编译选项:

if(UNIX)
    set_property(TARGET target APPEND_STRING PROPERTY LINK_FLAGS "-z noexecstack")
endif()

9.3. Conda

9.3.1. conda命令补全

参考: https://github.com/tartansandal/conda-bash-completion

采用方法2直接把 https://github.com/tartansandal/conda-bash-completion/blob/master/conda 下载到bash补全目录

9.4. Docker

9.4.1. Manage Docker as a non-root user

reference: https://docs.docker.com/engine/install/linux-postinstall/

  1. If docker group does not exit:

sudo groupadd docker
  1. Add your user to the docker group:

sudo usermod -aG docker $USER
  1. To activate the changes to groups:

newgrp docker

9.5. manylinux

centos7, glibc version 2.17

9.6. git

9.6.1. 在 HTTPS 端口使用 SSH

参考:https://docs.github.com/zh/authentication/troubleshooting-ssh/using-ssh-over-the-https-port

Host github.com
    Hostname ssh.github.com
    Port 443
    User git

9.7. Homebrew

由于tencent的homebrew源有问题,所以暂用科大源替代。

9.7.1. 科大源安装 Homebrew / Linuxbrew

首先在命令行运行如下几条命令设置环境变量:

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"

之后在命令行运行 Homebrew 安装脚本:

/bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/HEAD/install.sh)"

备注

若用户设置了环境变量 HOMEBREW_BREW_GIT_REMOTE,则每次运行 brew update 时将会自动设置远程。 推荐用户将环境变量 HOMEBREW_BREW_GIT_REMOTE 加入 shell 的 profile 设置中。

# 对于 bash 用户
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.bash_profile

# 对于 zsh 用户
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.zshrc

重置为官方地址:

unset HOMEBREW_BREW_GIT_REMOTE
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew

备注

重置回默认远程后,用户应该删除 shell 的 profile 设置中的环境变量 HOMEBREW_BREW_GIT_REMOTE 以免运行 brew update 时远程再次被更换。

若之前使用的 git config url.<URL>.insteadOf URL 的方式设置的镜像,请手动删除 config 文件(一般为 ~/.gitconfig 或仓库目录下的 .git/config)中的对应字段。

9.7.2. Linux Homebrew参考设置

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

if type brew &>/dev/null
then
    HOMEBREW_PREFIX="$(brew --prefix)"
    if [[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]
    then
        source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
    else
        for COMPLETION in "${HOMEBREW_PREFIX}/etc/bash_completion.d/"*
        do
            [[ -r "${COMPLETION}" ]] && source "${COMPLETION}"
        done
    fi
fi

9.7.3. 通过brew安装的vim启动时出现错误

解决方法:

brew reinstall --build-from-source vim

9.7.4. brew相关链接

科大文档:

https://mirrors.ustc.edu.cn/help/brew.git.html

官方主页:

http://brew.sh/

brew 文档:

http://docs.brew.sh/