如何在 Windows 7 中与 Cygwin 建立符号链接

发布于 2024-09-18 12:55:18 字数 131 浏览 6 评论 0原文

最近我测试了用 C/C++ 原生代码编写 Android 应用程序。问题在于使用 Android NDK 时创建符号链接。经过一番谷歌搜索后,有人说使用 Cygwin。我现在已经安装了。如何在 Windows 7 中与 Cygwin 建立符号链接?

Recently I have tested to write an Android application with native code in C/C++. The problem is in making symbolic links when using the Android NDK. After some googling, some say to use Cygwin. I have installed it now. How can I make a symbolic link with Cygwin in Windows 7?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

拥抱我好吗 2024-09-25 12:55:19

简而言之,定义以下环境变量:

CYGWIN=winsymlinks:nativestrict

根据 Cygwin 文档

如果设置为 winsymlinks:nativewinsymlinks:nativestrict,Cygwin 将在支持它们的文件系统和操作系统版本上创建符号链接作为本机 Windows 符号链接。

winsymlinks:nativewinsymlinks:nativestrict 之间的区别是:如果文件系统支持本机符号链接,并且 Cygwin 由于某种原因无法创建本机符号链接,它将回退到使用 winsymlinks:native 创建 Cygwin 默认符号链接,而使用 winsymlinks:nativestrict 时,symlink(2) 系统调用将立即失败。< /p>

您还应该确保以提升的权限运行 Cygwin(右键单击快捷方式并选择以管理员身份运行,或设置 mintty 快捷方式属性,高级 → 以管理员身份运行)。

其他答案中提供了一些详细信息。

In short, define the following environment variable:

CYGWIN=winsymlinks:nativestrict

According to Cygwin documentation:

If set to winsymlinks:native or winsymlinks:nativestrict, Cygwin creates symlinks as native Windows symlinks on filesystems and OS versions supporting them.

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.

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.

方觉久 2024-09-25 12:55:19

我第二天就收到了!所以,为了避免像我(Cygwin 新手)一样无知地思考,我现在回答这个问题。

使用常用命令为 Windows 7 创建符号链接很容易:

ln -s

答案是使用所需的包(例如 make 等)设置 Cygwin。

阅读要求显然:Android NDK

I got it the next day! So, not to wrongly get ignorance thinking like me (newbie to Cygwin), I answer it now.

Making a symbolic link for Windows 7 is easy with the usual command:

ln -s

The answer is setting up Cygwin with the required packages such as make, etc.

Read the requirements clearly: Android NDK

梦回梦里 2024-09-25 12:55:19

您可以尝试使用“mklink”而不是“ln -s”,正如 Tony O'Hagan 在 Git Bash shell 无法创建符号链接的答案

You may try to use "mklink" instead of "ln -s" as Tony O'Hagan suggested in an answer to Git Bash shell fails to create symbolic links.

绅士风度i 2024-09-25 12:55:19

我们遇到了类似的问题,并且有一个解决方案未记录在以前的答案中。

我们需要一种方法来创建一个适用于 Cygwin 和 Windows 7 的远程目录远程链接 Samba (Linux) 共享。

我们在 Windows PowerShell 中使用了此命令,并且它有效。

CMD /C MKLINK /D C:\local_dir_path\dir \\\\192.168.0.1\remote_dir_path\dir

上面的命令创建了一个在两者中都有效的链接。

当然,请更改本地和远程目录以满足您的需要。

ln -s 适用于 Cygwin,但不适用于 Windows。

在 Windows 资源管理器(文件夹视图)中使用“make link”命令可以在 Windows 中使用,但不能在 Cygwin 中使用。

在 Cygwin 中输入与上面类似的命令不起作用,我们不完全理解原因。可能与字符串或路径的转换有关。

We had a similar problem and had a solution not documented in previous answers.

We needed a way to create a directory remote link that worked for both Cygwin and Windows 7 to a remote Samba (Linux) share.

We used this command in Windows PowerShell and it worked.

CMD /C MKLINK /D C:\local_dir_path\dir \\\\192.168.0.1\remote_dir_path\dir

The above command makes a link that works in both.

Of course, please change the local and remote directories to meet your needs.

ln -s works in Cygwin, but not Windows.

Using a "make link" command in Windows Explorer (folder view) worked in Windows, but not in Cygwin.

A similar command as above entered in Cygwin did not work and we didn't completely understand why. Perhaps it is related to conversion of strings or paths.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文