Thread: gcc and cc can't recognize includes

  1. #1
    Registered User
    Join Date
    Apr 2015
    Posts
    180

    gcc and cc can't recognize includes

    Whenever i try to compile with either gcc or cc i get following error:

    fatal error: sys/types.h: No such file or directory
    #include <sys/types.h>

    I did this command that i found with a search
    Code:
    gcc -xc -E -v -
    and i got this as result at end of output
    Code:
    #include "..." search starts here:
    #include <...> search starts here:
     /usr/lib/gcc/x86_64-linux-gnu/4.8/include
     /usr/local/include
     /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
     /usr/include/x86_64-linux-gnu
     /usr/include
    End of search list.
    I took a look and all the files are sitting at /usr/include/linux/. Is there any way to tell it to search in this directory?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    A search of the Web for for "gcc modify default include path" provided some leads that might help.

    That said, if you want to add a directory to the include path whenever you compile, see: Options for Directory Search
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Explicating your gcc command:
    gcc -xc -E -v -
    -xc specify source language as c (cpp will attempt to determine base syntax without this)
    -E stop after preprocessing stage (no compiler or linker)
    -v verbose mode (shows final form of include path, etc.)

    Use -I/usr/include/linux/
    or maybe better: -isystem/usr/include/linux/ (for vendor-supplied system files)
    or add this to your .profile:

    C_INCLUDE_PATH=/usr/include/linux/
    export C_INCLUDE_PATH

    (or maybe the CPATH environment variable is more appropriate).

  4. #4
    Registered User
    Join Date
    Apr 2015
    Posts
    180
    Didn't work but solved it by installing package build-essential. If anyone has same problem this could solve. This was a fresh linux mint installation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc does not recognize my lib location
    By baxy in forum C Programming
    Replies: 2
    Last Post: 08-19-2013, 11:15 AM
  2. How to recognize an image on the screen
    By lala123 in forum C Programming
    Replies: 32
    Last Post: 02-17-2010, 08:08 PM
  3. Why can't it recognize template method?
    By 6tr6tr in forum C++ Programming
    Replies: 9
    Last Post: 04-12-2008, 10:34 AM
  4. A Function prototype I don't recognize...
    By DominicTrix in forum C++ Programming
    Replies: 4
    Last Post: 04-12-2003, 04:46 PM
  5. C++ code I can't recognize??
    By Guardian in forum Windows Programming
    Replies: 4
    Last Post: 04-29-2002, 04:31 PM