【问题标题】:cannot include header on linux subsystem with vs2017不能在带有 vs2017 的 linux 子系统上包含标头
【发布时间】:2018-11-18 18:59:38
【问题描述】:

我想在 Windows 10 的 linux 子系统 (ubuntu) 中使用带有 vs2017 的 C++ 程序中的 C++ OpenCascade (OCE) 库。

我将 OCE 编译到 linux 子系统中;我在 Windows 中也有 OCE 编译的二进制文件。

当我尝试在我的代码 (#include <Adaptor2d_Curve2d.hxx>) 中包含来自 OCE 的标头时,我收到此错误:

error : Adaptor2d_Curve2d.hxx: No such file or directory
error : #include <Adaptor2d_Curve2d.hxx>
error :          ^~~~~~~~~~~~~~~~~~~~~~~
error : compilation terminated.

我使用 $(ProjectDir) 或 $(RemoteRootDir) 路径在 additional include directories 的 vs 项目中添加了 OCE 包含路径。我检查了,路径是正确的。

我创建了一个 linux 控制台应用程序。 我的代码:

// from oce
#include <Adaptor2d_Curve2d.hxx>

int main()
{
   printf("hello from CAO3DConverterTestApp!\n");
   return 0;
}

我已将这些行添加到我的项目设置中的Additional Include Directories

$(ProjectDir)..\oce-0.18.3\include\oce
$(RemoteRootDir)..\oce\build\inc

那么在 Windows 10 的 linux 子系统中使用 vs2017 在 C++ 代码中添加外部库和头文件的过程是什么?

这是一个使用 Boost 依赖而不是 OCE 的最小项目

  • 使用 ubuntu linux 子系统,使用 vs2017 构建一个 c++ linux 控制台应用程序。
  • 在项目属性的Additional Include Directories 中包含提升标头路径

  • #include &lt;any.hpp&gt;(来自 boost 的标头)添加到 main.cpp 文件中

-I 语句是正确的-I "C:\&lt;myPath&gt;\dependencies\boost_1_68_0\boost\",但我仍然有错误

error : any.hpp: No such file or directory
error :  #include <any.hpp>
error :           ^~~~~~~~~
error : compilation terminated.

我还应该做什么?

参考:https://blogs.msdn.microsoft.com/vcblog/2017/02/08/targeting-windows-subsystem-for-linux-from-visual-studio/

【问题讨论】:

  • 您能否按照此处的要求在您的问题中提供 minimal reproducible example 自我。
  • 对不起,如果不够清楚,我编辑了

标签: c++ visual-studio ubuntu windows-subsystem-for-linux opencascade


【解决方案1】:

如果没有一个最小的示例,就无法真正调试您的项目,但这里有一些东西可以帮助您弄清楚发生了什么:

在 VS2017 中右键单击您的项目,选择属性。在 C/C++ 下选择命令行。 在这里,您可以看到 IDE 用于编译源文件的命令行。检查所有 /I 语句并确保其中一个指向 Adaptor2d_Curve2d.hxx 所在的位置。

【讨论】:

  • 我检查了 -I 语句,路径是正确的,但我仍然有错误。我已经使用 boost 库通过小地图项目解释编辑了我的问题
猜你喜欢
  • 2014-02-08
  • 1970-01-01
  • 2016-07-16
  • 2018-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-05
相关资源
最近更新 更多