如何在 Windows 7 中使用 cygwin 进行符号链接 [英] How to make symbolic link with cygwin in Windows 7
问题描述
最近我测试了使用原生代码 C/C++ 编写 Android 应用程序.问题在于使用 Android NDK 时进行符号链接.经过一番谷歌搜索,有人说要使用 cygwin.我现在已经安装了.请告诉我如何在 Windows 7 中与 cygwin 建立符号链接.
Recently I have tested to write Android application with native code C/C++. The problem is in making symbolic link when using Android NDK. After some Googling, some say to use cygwin. I have installed it now. Please tell me how to make symbolic link with cygwin in Windows 7.
提前致谢.
推荐答案
简单来说,定义如下环境变量:
In short, define the following environment variable:
CYGWIN=winsymlinks:nativestrict
根据Cygwin 文档:
如果设置为 winsymlinks:native
或 winsymlinks:nativestrict
,Cygwin 会在文件系统和支持它们的操作系统版本上创建符号链接作为本地 Windows 符号链接.
If set to
winsymlinks:native
orwinsymlinks:nativestrict
, Cygwin creates symlinks as native Windows symlinks on filesystems and OS versions supporting them.
winsymlinks:native
和 winsymlinks:nativestrict
之间的区别是:如果文件系统支持本地符号链接并且 Cygwin 由于某种原因无法创建本地符号链接,它将回退到使用 winsymlinks:native
创建 Cygwin 默认符号链接,而使用 winsymlinks:nativestrict
symlink(2)
系统调用将立即失败.
The difference between winsymlinks:native
and winsymlinks:nativestrict
is this: If the filesystem supports native symlinks and Cygwin fails to create a native symlink for some reason, it will fall back to creating Cygwin default symlinks with winsymlinks:native
, while with winsymlinks:nativestrict
the symlink(2)
system call will immediately fail.
您还应该确保以提升的权限运行 Cygwin(右键单击快捷方式并选择以管理员身份运行,或设置 mintty
快捷方式属性,高级 → 以管理员身份运行).
You should also make sure you run Cygwin with elevated privileges (right-click the shortcut and choose Run as Administrator, or set the mintty
shortcut property, Advanced → Run as Administrator).
其他答案中提供了一些详细信息.
Some details are provided in the other answer.
这篇关于如何在 Windows 7 中使用 cygwin 进行符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!