Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make symbolic link with cygwin in Windows 7

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.

Thanks in advance.

like image 748
aemon Avatar asked Sep 06 '10 03:09

aemon


People also ask

How do I create a symbolic link in Windows 7?

To create a symbolic link, open a command prompt with administrative privileges and use the mklink command. For example, the following command creates a symbolic link from C:\Myapp.exe to Notepad in the system directory. Note Developers can call the CreateSymbolicLink function to create symbolic links.

What is the command to create a symbolic link?

Ln Command to Create Symbolic Links Use the -s option to create a soft (symbolic) link. The -f option will force the command to overwrite a file that already exists. Source is the file or directory being linked to.

Do symlinks exist in Windows?

Overview. Symlinks, or symbolic links, are “virtual” files or folders which reference a physical file or folder located elsewhere, and are an important feature built in to many operating systems, including Linux and Windows. The Windows' NTFS file system has supported symlinks since Windows Vista.


1 Answers

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.

like image 168
oHo Avatar answered Sep 25 '22 13:09

oHo