I am using Visual Studio 2008 C++ project (Visa 32 bit).
I have the following #include directive in my source code.
#include <example/header.h>
In my include path I specify the parent directory of 'example', i.e.
C:/.../include
where the full path to the header looks like
C:/.../include/example/header.h
However, 'example' is a symbolic link (A '.lnk' created via file explorer 'new shortcut'). I get the following error
c:...\foo.cpp(37) : fatal error C1083: Cannot open include file: 'example/header.h': No such file or directory
If I replace the symbolic link with the actual directory, the project will compile correctly. For practical reasons I need it to be a symbolic link. Is there anyway to make the Visual Studio pre-processor follow the link?
The link is a symbolic link (.lnk)
Are you sure you're not creating a shortcut? Shortcuts work on a higher level than symbolic links and mean nothing to applications.
Conversely, symbolic links (if properly created) should work fine with any application that reads/writes to files/folders.
For more details, you may wish to consider reading this article about symbolic links, which explains how you can create a symbolic link using mklink
.
Here's a helpful snippet from a comment on that article by "Bernard Kerckenaere":
shortcut: on the operating system level (to applications who wish to read/write the link, it’s just a meaningless file)
soft link (or symbolic link): like a shortcut, but on the filesystem level (applications reading/writing the link, will actually read/write the file linked to) ... this will work across partitions, or drives
hard link: only for files, what happens is that there are multiple file entries that point to the same physical data, when you delete one entry, the other will still work, the data won’t be gone until all entries are deleted (if with a soft link you delete the original directory, the link won’t work anymore!) -> you can obviously only create hard links to a file on the same partition
What you want to create is a symbolic link which you can do with the /D
parameter using mlink.
.lnk is not symbolic link, it is shortcut file for Explorer. To create hard link, use
fsutil hardlink create link_name file_name
On Vista, there is mklink utility to create symbolic links.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With