programing tip

C 표준 라이브러리 헤더 용 Eclipse CDT의 "해결되지 않은 포함"오류

itbloger 2020. 8. 27. 07:25
반응형

C 표준 라이브러리 헤더 용 Eclipse CDT의 "해결되지 않은 포함"오류


이클립스 용 CDT를 설정하고 간단한 hello world C 프로그램을 작성했습니다.

#include <stdio.h>

int main(void){
    puts("Hello, world.");
    return 0;
}

프로그램은 올바르게 빌드되고 실행되지만 eclipse "Unresolved inclusion: <stdio.h>"는 마우스를 올려 놓을 때 말하는 포함 문 옆 에이 노란색 물음표를 계속 표시 합니다.

프로그램 실행에는 영향을주지 않지만 다소 짜증이납니다.

누구든지 그것을 제거하는 방법을 알고 있습니까?


Eclipse가 사용하는 컴파일러는 기호를 잘 해결할 수 있으므로 코드가 잘 컴파일됩니다.

그러나 Eclipse가 사용하는 코드 완성 / 전처리 기는 stdio.h가 어디에 있는지 모릅니다.

stdio.h가있는 파일 시스템 경로를 지정해야합니다.

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


나는 (허용되는 것을 포함하여) 이러한 답변이 다소 모호하다는 것을 알았습니다.

나를 위해 stdio.h가있는 경로를 추가해야했습니다 (@ardnew가 말했듯이). Eclipse에서 프로젝트의 속성을 열고 "C / C ++ General"을 확장 한 다음 "Paths and Symbols"를 선택합니다.

include사용중인 각 언어 에 대한 dir을 추가했는지 확인하십시오 . (제 경우에는 GNU C ++에 추가해야했습니다.)

여기에 이미지 설명 입력


지식 기반에 추가하는 것뿐입니다. 저는 cygwin으로 win7에서이 작업을 수행했습니다.

이것은 나를 위해 일하는 것 같습니다.

c에 대한 경로 포함 :

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

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

이것은 나에게 hello world의 깨끗한 컴파일을 얻습니다.


프로젝트> 속성> C / C ++ 일반> 전 처리기 포함> 공급자로 이동하고 둘 다 선택합니다.

  • "CDT GCC 내장 컴파일러 설정"
  • "CDT CROSS GCC 내장 컴파일러 설정"

For each one of those also select the sub-entry: "Use global provider shared between projects".

Tested on Eclipse 4.8.0 in Ubuntu 16.04 with a C and a C++ hello world.


  • Select File>>New Project
  • In the Project Wizard, select C/C++>> C++ Project
  • In "Project type" section, select "Makefile Project>> Hello world C++ Project"
  • In "Toolchains" section, select "Linux GCC"

It can solve the problem. (Excuse me for bad English)


I'm using Eclipse with Cygwin and this worked for me:

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


I'm working with multiple cross compiler configurations, where I need to use different locations for the STD header files (and other environment variables).

The solution was to set up the indexer so it uses the active configuration.
Unfortunately due to some bug in eclipse, the option isn't stored locally, so you have to use the workspace configuration if you want to save the configuration when you open eclipse again.

Window -> Preferences -> C/C++ -> Indexer -> Use active build configuration

This will make eclipse use the right compiler that is set with the project's active Cross GCC configuration.


In ADT I did the following:

  1. right click on the project and select Properties
  2. expand C/C++ General and select Preprocessor Include Paths, Macros etc.
  3. select CDT User Setting Entries
  4. select Add... from the right hand menu
  5. In the Add Include Directory change Project Path to File System Path
  6. Browse to the directory that contains your include files
  7. stir and repeat as needed

Normally, Eclipse should be able to automatically resolve the standard include files. It does this by calling gcc and asking its configuration. Most likely Eclipse is not finding your gcc (or at least not the version you use for compiling).

Instead of specifying all the standard include paths in project settings, you probably want to make sure Eclipse finds gcc. Add the directory where gcc is found to PATH environment variable before starting Eclipse.

If you want different projects to use different compilers, then you might want to tweak the discovery options. These are hidden by default, so first enable them from Window > Preferences > C/C++ > Property Pages Settings > Display "Discovery Options" page. Then you can find them under C/C++ Build > Discovery Options in project properties.


I m using eclipse based CodeWarrior IDE for embedded projects and i have just solved this problem by deleting and adding again the source adresses to Project Properities->C/C++ General->Path and Sybols-> Include Directories. This means that there lots of reason to take "Unresolved inclusion:" message and there r lots of solution too.


An error I had configuring Paths and Symbols is that initially I configued the include paths for a different language. I'm working with CDT and Cygwin gnu C++. So you must configure symbols and paths under GNU C++ language.여기에 이미지 설명 입력


As the top answers note, it's necessary to specify where the build folders are located, which can be added via a dialog reached by right-clicking the project, and selecting Properties->C/C++ General->Paths and Symbols.

The remaining question is what paths need to be added.

If you have gcc set up correctly for command-line access, and need to know what the default include paths it uses are, just ask it; depending on which language you're interested in, use:

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

...this will list the default compiler settings that are used when invoking gcc (and this command also works if "gcc" is really an alias for clang, as on OSX).

/dev/null is used an empty file - we're telling gcc to parse an empty file

-x <language> specifies the language to compile as, necessary because we're not using a file with an extension that specifies the language

-v verbose output, which includes outputting the include paths

-E only perform preprocessing, output the preprocessed file (this prevents gcc from complaining that an empty file doesn't compile correctly)

Toward the bottom will be the list of include 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 the order listed, into Eclipse's paths and symbols dialog, Eclipse CDT should be able to find the standard headers, and perhaps some additional headers specific to your OS.

( 관련 질문에 대한 devnull의 답변 덕분에 .)

참고 URL : https://stackoverflow.com/questions/9337757/unresolved-inclusion-error-with-eclipse-cdt-for-c-standard-library-headers

반응형