1

I'm experimenting with developing C code for linux using VS2019.

I'm finding that whilst many Linux headers such as sys/types.h and sched.h are being found OK, others, such as sys/syscall.h and fcntl.h are not being found.

I can see that it has a local copy of many headers such as stdint.h in local linux platform directory...can I just cut and paste the missing ones from the target machine?

I rather suspect that if common headers such as unistd.h are missing there is a reason, and I don't want to mess things up!

  • 1
    Start out by having a look at [What are the differences between Visual Studio and Visual Studio Code?](https://stackoverflow.com/questions/30527522/what-are-the-differences-between-visual-studio-code-and-visual-studio) – John Bollinger Feb 22 '19 at 13:49

1 Answers1

5

From Microsoft's documentation:

By default, Visual Studio does not include any system-level include files from the Linux computer. For example, items in the /usr/include directory are not present in Visual Studio. For full IntelliSense support, you will need to copy those files to some location on your development computer and point Visual Studio to this location. One option is to use scp (Secure Copy) to copy the files. On Windows 10, you can use Bash on Windows to run scp. For previous versions of Windows, you could use something like PSCP (PuTTY Secure Copy).

You can copy the files by using a command similar to the following:

scp -r linux_username@remote_host:/usr/include .

Of course, replace the linux_username and remote_host values above for what's appropriate in your own environment.

Once the files are copied, use the VC++ Directories item in Project properties to tell Visual Studio where to find the additional include files that were just copied.

Layne Bernardo
  • 676
  • 3
  • 12
  • 2
    Newer versions of Visual Studio will now automatically import remote headers. See https://learn.microsoft.com/en-us/cpp/linux/configure-a-linux-project?view=vs-2019#remote_intellisense – Joe Coder May 31 '19 at 07:14