分类 Windows 下的文章
Windows 环境变量
在写一些脚本或软件的时候,需要索引或存储文件到特定的目录,但由于客户机上用户名,磁盘名等各不相同,往往不能很好的通过一个固定链接访问到目标路径。这时候可以使用系统环境变量(Environment Variable) 来实现需求。
如果我要访问用户系统根目录,一般情况下路径为:C:
。但是有些人的系统目录在 D 盘,这时候就出错了。如果使用 %SystemDrive%
变量来代表系统目录,就会自动识别系统路径,访问到目标结果。
注意再终端里,cmd 使用百分号形式表示环境变量:%variable-name%
,power shell 中使用:$Env:<variable-name>
形式来使用环境变量。
下面表格列出常用的环境变量:
编译 boost lib 库
boost 是很流行的一个 c++ 库,他的部分模块使用只需要引用 head 文件即可,部分需要编译链接库才能使用。下面介绍如何编译模块的静态链接库。
官方网站:https://www.boost.org/
开始教程:https://www.boost.org/doc/libs/1_72_0/more/getting_started/windows.html
官方编译教程:https://www.boost.org/doc/libs/1_72_0/more/getting_started/windows.html#prepare-to-use-a-boost-library-binary
关于 B2 编译系统:https://boostorg.github.io/build/
关于 Microsoft Visual C++(MSVC) 版本号:https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering
关于静态库和动态库:https://blog.csdn.net/qq_41979948/article/details/129693847
WSL 下使用 VS Code 编辑器
Windows Subsystem for Linux (WSL) 就是 Windows 10 下安装的 Linux 子系统,有了它可以很方便的使用 Linux,WSL 也可以很方便的访问本地磁盘文件。
vs code 已经成为目前个平台最流行的代码编辑平台,也是我最常用的编辑器,通过插件设置,可以在 WSL 环境下使用 vs code,这对于环境开发和编辑工作有极大的帮助,下面介绍设置方法。
相关链接:
- Windows 10 上使安装 WSL:https://niekun.net/index.php/archives/1148.html
- 在 Windows 和 WSL 中共享 Git 证书:https://niekun.net/index.php/archives/1159.html
- 在 Git 中缓存 GitHub 密码信息:https://niekun.net/index.php/archives/444.html
在 Windows 和 WSL 中共享 Git credentials 证书
将 Git 的 credential 证书保留在系统,可以避免每次操作都需要输入账户密码。
各系统中设置缓存参考我的文章:https://niekun.net/index.php/archives/444.html
对于 Windows 10 用户,系统内置了 Windows subsystem for Linux (WSL),我们可以共享存储在本地的 Git credential 证书,这样两个系统使用 git 都很方便。
关于 WSL 的安装与使用参考:https://niekun.net/index.php/archives/1148.html
首先在 Windows 10 下设置 credentials,在 power shell 下输入如下命令:
git config --global credential.helper wincred
可以在仓库内测试执行 git push 命令,如果提示输入账户密码,则输入一次,以后就不会再提示了。
然后在 WSL 设置,打开系统内安装好的 WSL,首先安装好 git,然后敲入如下命令:
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe"