Unauthorized inclusion error with Eclipse CDT for standard C library headers

I installed the CDT for eclipse and wrote a simple Hello World program:

#include <stdio.h> int main(void){ puts("Hello, world."); return 0; } 

The program builds and works correctly, but eclipse continues to show this yellow question mark on the side of the inclusion statement, which says "Unresolved inclusion: <stdio.h>" when I hover over it.

This does not affect the program, but I find it rather annoying.

Does anyone know how to remove it?

+92
c eclipse eclipse-cdt standard-library
Feb 18 2018-12-18T00:
source share
12 answers

The compiler that uses Eclipse is able to correctly resolve characters, so the code will compile fine.

But using the code / preprocessor used by Eclipse does not know where stdio.h exists.

You need to specify the path to the file system where stdio.h is located.

See: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.cdt.doc.user/tasks/cdt_t_proj_paths.htm

+48
Feb 18 2018-12-18T00:
source share

I found these answers (including accepted) somewhat cryptic.

For me, I had to add the path where stdio.h is located (as indicated by @ardnew). In Eclipse, you open the Properties of your project, expand "C / C ++ General" and select "Paths and Symbols."

Make sure you add an include directory for each language you use. (In my case, I just needed to add it to GNU C ++.)

enter image description here

+47
Aug 13 2018-12-12T00:
source share

just adding to the knowledge base, I just did it on win7 with cygwin.

this is what seems to work for me.

include paths for c:

 D:\dev\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include D:\dev\cygwin\usr\include 

include paths for C ++:

 D:\dev\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include D:\dev\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include\c++ D:\dev\cygwin\usr\include 

it gives me a clean compilation of hi world.

+17
Oct 13
source share

Go to Project> Properties> C / C ++ General> The preprocessor includes> Providers and select both:

  • "CDT GCC Embedded Compiler Settings"
  • "CDT CROSS GCC Embedded Compiler Settings"

For each of them, also select the sub-item: "Use a global provider shared by projects."

Tested on Eclipse 4.8.0 on Ubuntu 16.04 with the world of C and C ++ hello.

+16
Nov 11 '14 at 11:30
source share
  • Choose File → New Project
  • In the Project Wizard, select C / C ++ → C ++ Project
  • In the "Project Type" section, select " Makefile Project → Hello world C ++ Project "
  • In the "Toolchains" section, select " Linux GCC "

He can solve the problem. (Excuse me for bad english)

+10
May 03 '12 at 16:47
source share

I am using Eclipse with Cygwin and this worked for me:

Go to Project> Properties> C / C ++ General> The preprocessor turns on ...> Providers and select "GCC Cygwin [Shared] Built-in CDT Compiler Settings".

+4
Dec 02 '14 at 6:42
source share

I work with multiple cross-compiler configurations where I need to use different locations for STD header files (and other environment variables).

The solution was to configure the indexer to use the active configuration.
Unfortunately, due to an error in eclipse , this parameter is not saved locally, so you need to use the workspace if you want to save the configuration when you open eclipse again.

Window → Settings → C / C ++ → Indexer → Use Active Build Configuration

This will force eclipse to use the correct compiler that installs with the active Cross GCC configuration of the project.

+4
Nov 02 '15 at 11:34
source share

In ADT, I did the following:

  • right click on the project and select "Properties"
  • expand C / C ++ General and select Preprocessor Include Paths, Macros, etc.
  • select custom CDT entries
  • select Add ... from the menu on the right.
  • In the Add Include Directory, change the path to the file system path
  • Change to the directory containing your included files.
  • mix and repeat as needed
+1
Jun 18 '14 at 18:20
source share

Normally, Eclipse should be able to automatically resolve standard include files. He does this by calling gcc and requesting its configuration. Most likely, Eclipse will not find your gcc (or at least not the version you use to compile).

Instead of specifying all the standard inclusions in your project settings, you probably want to make sure that Eclipse finds gcc. Add the directory where gcc is in the PATH environment variable before running Eclipse.

If you want different projects to use different compilers, you can configure detection options. They are hidden by default, so first enable them from the window> Settings> C / C ++> Properties of the property page> Display the "Search options" page. Then you can find them in the C / C ++ Build> Discovery Options section in the project properties.

+1
May 7 '15 at 7:15
source share

As noted in the top answers, you must specify where the assembly folders are located, which can be added using the dialog box, by right-clicking on the project and choosing Properties-> C / C ++ General-> Paths and Symbols.

The question remains, which paths should be added.

If you have gcc configured correctly for command line access, and you need to know which default paths include the paths used, just ask it; depending on which language interests you, use:

 gcc -xc -v -E /dev/null gcc -x c++ -v -E /dev/null 

... the default compiler options that are used when calling gcc will be listed here (and this command also works if "gcc" is really an alias for clang, as in OSX).

/dev/null empty file is used - we tell gcc to parse the empty file

-x <language> defines the language for compilation as necessary, because we do not use a file with the extension that defines the language

-v verbose output, which includes output paths

-E performs only preprocessing, displays the preprocessed file (this prevents gcc from complaining that the empty file is not compiling correctly)

Below is a list of included directories:

 #include "..." search starts here: #include <...> search starts here: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks (framework directory) End of search list. 

If you enter the directories listed here in this order into the Eclipse paths and symbols dialog box, Eclipse CDT will be able to find the standard headers and possibly some additional headers specific to your OS.

(Thanks to Devnull, the answer to a related question.)

+1
Feb 01 '16 at 23:01
source share

I am using Eclipse based on the CodeWarrior IDE for embedded projects, and I just solved this problem by removing and adding the source addresses again in Project Properities-> C / C ++ General-> Path and Sybols-> Include Directories. This means that there are many reasons to accept the message "Unauthorized inclusion:", as well as many decisions.

+1
Jun 29 '17 at 15:29
source share

The error with which I set up Paths and Symbols is that I initially configured include paths for another language. I work with CDT and Cygwin gnu C ++. Therefore, you must configure characters and paths under the GNU C ++ language. enter image description here

0
Jan 16 '16 at 14:56
source share



All Articles