0

I programmed my code in Linux and it is compiled in Linux platform, recently, I have imported the code in visual studio 2017 enterprise under cross-platform project. my remote builder is the machine which the code had been compiled on it. but when trying to build the project by VS, it could not find some header files such as or or etc. and build would be failed.

I found that VS paths for includes files (VC\Linux\include\usr\include\c++\5 and etc) do not contain the missing header files. But Microsoft community express that this missing just cause IntelliSense to malfunction and code must complied on remote builder by VS!!

#include <errno.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
.
.
.
int main(int argc, char **argv)
{   
     char device_string[1000];
     char * reordered;
     BIO *bio, * b64;
     BUF_MEM * b64buff;
...
}

Error (active) E1696 cannot open source file "unistd.h" Hardware-Check

etc.

arsdever
  • 1,111
  • 1
  • 11
  • 32
  • 6
    `unistd.h` is not a standard C++ header - it's a posix header which is why it works on linux. – Ted Lyngmo May 19 '19 at 10:08
  • 1
    Did you install Linux cross-compilation components in VS? They are optional by default. – rustyx May 19 '19 at 10:11
  • Thank you for your response. But this is exactly my question, how should I deal with non-standard header files in Visual studio 2017? – shahramy May 19 '19 at 10:12
  • VS should be able to locate them. There is probably some problem with your setup. Can you compile this code on that machine without VS? – user7860670 May 19 '19 at 10:16
  • No I can not. the problem is that Windows does not have some libraries. I want to make the code by VS on Windows but by defined remote builder in VS. As I mentioned the code was compiled in Linux (Debian 8) – shahramy May 19 '19 at 10:40
  • I have installed everything with visual studio installer but "Visual C++ tools for Cmake and Linux", is this matter? – shahramy May 19 '19 at 10:45
  • Try replacing all the non-standard functions used in the program with functions included in the C++ standard. For the remaining platform dependent functions you need to implement your own functions by using the Windows API. – Ted Lyngmo May 19 '19 at 11:33
  • As it turns out, I had misunderstood the way that visual studio 2017 cross platform works. We can not just import the projects which have been written for Linux to VS and compile it. VS has it own workaround and Linux has its own. – shahramy May 20 '19 at 06:33

1 Answers1

-1

unistd.h,fcntl.h etc are header files in Unix standard.It can't be found in Windows OS,if you want to compile your code in both platform,maybe you can write your code like this:

#ifdef _WIN32
//code for windows
#elif defined __linux__
//code for linux
#endif
kangsouth
  • 73
  • 8