Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot open include file: 'unistd.h': No such file or directory

Tags:

c++

unistd.h

After having installed libpng into my computer, I've included it into my project using #include <png.h> on a Windows 7 SP1 plateform and using Visual Studio Ultimate 2013.

But at build time, I'm getting this error:

C1083: Cannot open include file: 'unistd.h': No such file or directory

How do I please to fix this? I haven't found yet any solution in the net?

like image 674
user3471387 Avatar asked Mar 28 '14 06:03

user3471387


People also ask

How do I add Unistd h to Visual Studio?

If you write #include <unistd. h>, you must put that file in "include" folder of visual studio (Installation directory). If you are doing write, please refer the following links for more information on error.

What is the meaning of #include Unistd h?

In the C and C++ programming languages, unistd. h is the name of the header file that provides access to the POSIX operating system API. It is defined by the POSIX. 1 standard, the base of the Single Unix Specification, and should therefore be available in any POSIX-compliant operating system and compiler.

Where is Unistd h in Ubuntu?

Solution: Delete /usr/local/include/unistd. h . That way the real header at /usr/include/unistd. h can be found and used again.

Is Unistd h standard library?

No, unistd. h and fcntl. h , etc are not part of standard C.


2 Answers

The "uni" in unistd stands for "UNIX" - you won't find it on a Windows system.

Most widely used, portable libraries should offer alternative builds or detect the platform and only try to use headers/functions that will be provided, so it's worth checking documentation to see if you've missed some build step - e.g. perhaps running "make" instead of loading a ".sln" Visual C++ solution file.

If you need to fix it yourself, remove the include and see which functions are actually needed, then try to find a Windows equivalent.

like image 140
Tony Delroy Avatar answered Oct 08 '22 19:10

Tony Delroy


If you're using ZLib in your project, then you need to find :

#if 1 

in zconf.h and replace(uncomment) it with :

#if HAVE_UNISTD_H /* ...the rest of the line 

If it isn't ZLib I guess you should find some alternative way to do this. GL.

like image 43
Grokking Avatar answered Oct 08 '22 18:10

Grokking