编译器不遵循Visual Studio C ++中的符号链接 [英] Compiler not following symbolic links in Visual Studio C++

查看:237
本文介绍了编译器不遵循Visual Studio C ++中的符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Visual Studio 2008 C ++项目(Visa 32位)。



我在我的源代码中有以下 #include

  #include< example / header.h> 

在我的包含路径中,我指定父目录'example'

  C:/.../ include 

其中标题的完整路径如下所示

  C:/ .. ./include/example/header.h 

但是,example是一个符号链接(通过文件资源管理器创建的'.lnk'新快捷方式)。我收到以下错误


c:... \foo.cpp(37):致命错误C1083:无法打开包含文件: 'example / header.h':没有这样的文件或目录


如果我将符号链接替换为实际目录,项目将正确编译。出于实际原因,我需要它是一个象征性的链接。是否还有使Visual Studio预处理器遵循链接?

解决方案


链接符号链接(.lnk)


您确定不是在创建快捷方式吗?快捷键的工作级别高于符号链接,对应用程序没有任何意义。



相反,符号链接(如果已正确创建)文件/文件夹。



有关详细信息,您可以考虑阅读此关于符号链接的文章,说明如何使用 mklink

以下是对Bernard Kerckenaere对该文章评论的有用代码段:



  • 快捷键:在操作系统级别(希望
    读/写链接的应用程序只是一个
    无意义文件) / p>


  • 软链接(或符号链接):像快捷方式,但是在文件系统级别
    (应用程序读/写
    链接,将实际读/写
    文件链接到)
    ...
    这将工作在分区或驱动器


  • 硬链接:仅用于文件,发生的情况是,有多个
    文件条目指向相同的
    物理数据,当您删除一个
    条目,另一个仍然工作,
    数据将不会删除,直到所有条目
    被删除(如果使用软链接你
    删除原始目录,
    链接将不再工作了!)
    - >显然只能在同一分区上创建指向文件的硬链接。



您要创建的是符号链接,您可以使用mlink将 / D 参数进行。


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.

这篇关于编译器不遵循Visual Studio C ++中的符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆