cannot include header on linux subsystem with vs2017

562 views Asked by At

I want to use C++ OpenCascade (OCE) libraries within a C++ program with vs2017 inside a linux subsytem (ubuntu) from windows 10.

I compiled OCE into the linux subsystem; I also have the OCE compiled binaries in windows.

When I try to include a header from OCE in my code (#include <Adaptor2d_Curve2d.hxx>), I get this error :

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

I added OCE include path in my vs project in additional include directories from using $(ProjectDir) or $(RemoteRootDir) path. I checked, the paths are corrects.

I have created a linux console application. My code :

// from oce
#include <Adaptor2d_Curve2d.hxx>

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

I've added theses lines into Additional Include Directories in my project settings

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

So what is the procedure to add external libs and headers in C++ code using vs2017 in linux subsystem from windows 10 ?

Here is a minimal projet with Boost dependancies instead of OCE

  • build a c++ linux console app with vs2017, using ubuntu linux subsytem.
  • include boost headers path in Additional Include Directories from project properties

  • add #include <any.hpp> (header from boost) into main.cpp file

The -I statements are corrects -I "C:\<myPath>\dependencies\boost_1_68_0\boost\", but I still have the error

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

What else should I do ?

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

1

There are 1 answers

1
uceumern On

Can't really debug your project without a minimal example, but here is something that can help you figure out what is going on:

In VS2017 right click your project, select properties. Under C/C++ choose command line. Here you can see the command line the IDE is using to compile your source files. Check all /I statements and make sure one of them points to where Adaptor2d_Curve2d.hxx is located.