【问题标题】:Must NuGet configure project's include paths?NuGet 必须配置项目的包含路径吗?
【发布时间】:2017-12-06 23:00:45
【问题描述】:

我已经下载了Dropbox CPP REST sample from official MS site。为了使用 cpprestsdk,我要求 NuGet 下载包。它已经为各种工具集下载了包:

当我构建项目时出现错误:

Severity    Code    Description Project File    Line    Suppression State
Error   C1083   Cannot open include file: 'uri.h': No such file or directory    DropboxApp  d:\code_podurirest0813\dropboxapp\dropboxapp\oAuth.h    30  

uri.h 是库的一部分。我期待 NuGet 在项目中设置包含路径。是我期望太高还是可能有其他问题?

更新

MS Dropbox 示例对将 uri.h 更改为 cpprest\uri.h 不满意。它找不到新的包括它。

由于这个原因,我创建了自己的控制台应用程序并要求 NuGet 下载 cpprestsdk。程序完成后,我发现没有执行自动库和包含路径设置:

1>  Creating directory "D:\Code_PoduriREST0813\2012\ConsoleApplication1\Debug\".
1>InitializeBuildStatus:
1>  Creating "Debug\ConsoleApplication1.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1>  stdafx.cpp
1>  ConsoleApplication1.cpp
1>d:\code_podurirest0813\2012\consoleapplication1\consoleapplication1\consoleapplication1.cpp(5): fatal error C1083: Cannot open include file: 'cpprest\uri.h': No such file or directory

【问题讨论】:

    标签: visual-studio nuget nuget-package casablanca cpprest-sdk


    【解决方案1】:

    我期待 NuGet 在项目中设置包含路径。是我期望太高还是可能有其他问题?

    不,安装该软件包后,NuGet 会自动设置头文件和库路径,无需手动添加。但是我们应该仔细考虑如何包含头文件。您会注意到“include”文件夹中有两个子文件夹“cpprest”、“pplx”。所以我们应该使用“cpprest\uri.h”来包含头文件:

    所以请检查项目中包含头文件的方式。

    更新:

    我注意到不同之处在于你的Visual Studio 版本是2012(NuGet 的默认版本是2.8.6),我的Visual Studio 是2015(NuGet 的版本是3.4.4)。然后我在 Visual Studio 2012 和 2013 上测试它,只在 Visual Studio 2012 上失败,不知道为什么旧版本的 NuGet(2.8.6) 不能自动设置库和头文件路径。但是,我们无法在 Visual Studio 2012 中使用新版本的 NuGet,因此要解决此问题,我们必须手动添加库和头文件的路径,或者您可以将 Visual Studio 更新到 2013 及更高版本。

    【讨论】:

    • 设置 cpprest\uri.h 在我的情况下没有帮助。我已经更新了更多详细信息的消息正文
    • @vico,感谢您的回复。我发现这个问题的原因是旧版本的 NuGet。要解决此问题,我们必须手动添加路径或将您的 Visual Studio 更新到 2013 及更高版本。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-20
    • 2019-04-21
    • 2018-11-22
    相关资源
    最近更新 更多