IT TIP

Eclipse CDT : 'cout'기호를 확인할 수 없습니다.

itqueen 2020. 12. 6. 22:28
반응형

Eclipse CDT : 'cout'기호를 확인할 수 없습니다.


오류는 위와 같습니다. 이클립스 프로젝트에 필요한 모든 파일이 있어야합니다.

/usr/include/c++/4.6
/usr/include
/usr/include/linux
/usr/local/include

기타

나는 시도 std::cout하고 using namespace std; cout있지만 아직 해결되지 않은 말했다.

내가 가져온 iostreamcstdlib.

또한 eclipse 3.7.2가 설치된 Ubuntu 12.04에 있습니다.

코드 조각 :

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include "XPLMDisplay.h"
#include "XPLMGraphics.h"

int XPluginStart(char * outName,  char * outSig,  char * outDesc) {
    /* ... */
    std::cout << "test" << std::endl;
    /* ... */
}

네임 스페이스 std 사용;


업데이트 : 기존 코드에서 이클립스 프로젝트를 만들었습니다. 새 C ++ 프로젝트를 만들면 문제가 해결됩니다. 기존 프로젝트의 어떤 설정으로 인해이 문제가 발생할 수 있는지 설명하는 답변을 수락하겠습니다 (모든 프로젝트를 잘라내어 붙여 넣을 필요가 없음).


대부분의 경우 인덱서가 iostream을 올바르게 구문 분석 할 수 없게하여 오류가 발생하는 일부 시스템 특정 포함 디렉터리가 설정에 없습니다. Index -> Search For Unresolved Includes프로젝트의 컨텍스트 메뉴에서 선택하면 프로젝트 속성에서 /usr/include포함하는 디렉토리를 검색 하고 추가 할 수있는 해결되지 않은 포함 목록이 제공됩니다 C++ Include Paths and Symbols.

내 시스템에서 해결 /usr/include/c++/4.6/x86_64-linux-gnu하기 bits/c++config.h위해 몇 개의 디렉토리 를 추가해야했습니다 .

포함 디렉터리를 추가 한 후 인덱스를 다시 작성하는 것을 잊지 마십시오 (Index-> ​​Rebuild).


원하지 않는 기호 경고를 제거하려면 먼저 Eclipse CDT가 처음에 알 수없는 기호 경고를 일반적으로 어떻게 표시하는지 이해해야합니다. 이것은 그 과정입니다.

  1. Eclipse는 시스템에서 사용 가능한 GCC 툴체인을 감지합니다.
  2. Eclipse 프로젝트가 특정 도구 체인을 사용하도록 구성되었습니다.
  3. Eclipse는 도구 체인에서 검색을 수행하여 포함 경로 및 내장 정의를 찾습니다 (예 : 관련 옵션으로 실행하고 출력 읽기).
  4. Eclipse는 포함 경로에서 헤더 파일을 읽습니다.
  5. Eclipse는 프로젝트의 소스 코드를 인덱싱합니다.
  6. Eclipse는 편집기에서 해결되지 않은 기호에 대한 경고를 표시합니다.

포함 디렉터리, 기호 등을 수동으로 추가하여 결과를 재정의하는 것보다 이전 단계의 문제를 수정하는 것이 장기적으로 더 나을 수 있습니다.

툴체인

당신은 GCC가 설치되어 있고, 이클립스를 감지하면, 그것은 또한에 표시하는 새로운 C ++ 프로젝트에 사용할 수있는 툴체인의 선택으로 그 GCC 나열해야합니다 Window -> Preferences -> C/C++ -> New CDT Project Wizard상의 Preferred Toolchains탭의 Toolchains오른쪽에있는 상자를. 표시되지 않는 경우 특수 환경이 필요한 컴파일러에 대한 CDT FAQ의 답변을 참조하십시오 ( Windows 사용자를위한 MinGWCygwin 답변).

기존 Eclipse C ++ 프로젝트가있는 경우 프로젝트 속성을 열고 풀다운 C/C++ Build -> Tool Chain Editor에서 원하는 도구 체인으로 이동하여 선택하여 연관된 도구 체인을 변경할 수 있습니다 Current toolchain:. ( Display compatible toolchains only원하는 툴체인이 이전에 프로젝트에 설정된 툴체인과 충분히 다른 경우 먼저 상자 를 선택 취소해야합니다 .)

Eclipse를 시작한 후 시스템에 도구 체인을 추가 한 경우 도구 체인을 감지하려면 다시 시작해야합니다.

발견

그런 다음 프로젝트가 C/C++ Build -> Discovery Options -> Discovery profiles scope로 설정된 Per Language경우 다음 빌드 중에 프로젝트와 연결된 새 도구 모음이 포함 경로 및 기호의 자동 검색에 사용되며 표시되는 "내장"경로 및 기호를 업데이트하는 데 사용됩니다. 최대 프로젝트의 C/C++ General -> Paths and SymbolsIncludesSymbols탭.

인덱싱

때로는 도구 체인을 설정하고 빌드를 수행 한 후에 다시 색인을 생성해야 이전 기호 경고가 사라지게됩니다. 프로젝트 폴더를 마우스 오른쪽 버튼으로 클릭하고 이동 Index -> Rebuild하십시오.

(Eclipse 3.7.2 / CDT 8로 테스트 됨)


위의 답변에 감사드립니다. 특정 사용 사례에 대한 답변을 추가하고 있습니다.

이 목표 아키텍처와 프로젝트에 자신의 빌드 구성 각 (주요 목표는 임베디드 AVR 플랫폼입니다, 두 번째 목표는 단위 테스트를 실행하는 내 로컬 리눅스 PC입니다) 나는 세트가 필요하다고 Preferences -> C/C++ -> Indexer -> Use active build configuration추가 할뿐만 아니라 /usr/include/c++/4.7, /usr/include/usr/include/c++/4.7/x86_64-linux-gnuProject Properties -> C/C++ General -> Paths and Symbols그런 다음 색인을 다시 작성하십시오.


먼저 여기에 표시된 솔루션을 시도했습니다. 작동했지만 다소 해키가 있으며 gcc를 업데이트 할 때마다 다시 실행해야합니다. 마침내 다음을 수행하여 더 나은 솔루션을 찾습니다.

  1. Project-> Properties-> C/C++ General->Preprocessor Include Paths, Macros, etc.
  2. Providers -> CDT GCC built-in compiler settings
  3. 선택 취소 Use global provider shared between projects(필요에 따라 글로벌 공급자를 수정할 수도 있음)
  4. 에서 Command to get compiler specs, 추가 -std=c++11
  5. Index->Rebuild

짜잔, 쉽고 간단합니다. 도움이 되었기를 바랍니다.

참고 : 저는 Kepler에 있습니다. 이것이 이전 Eclipse에서 작동하는지 확실하지 않습니다.


우분투 12.04 / 이클립스 4.2.1 / CDT 8.1.1을 사용하고 있고 꽤 오랫동안 같은 문제가있었습니다. SVN에서 C ++ 프로젝트를 가져 오면 이러한 성가신 "미해결 포함"오류가 발생하고 대신 생성해야합니다. 새로운 프로젝트를 만들고 거기에 파일을 복사하십시오 (SVN 기능이 없기 때문에 여전히 부분적입니다!).

마침내 간단하고 만족스러운 해결책을 찾았습니다.

  • 로 이동하여 Project -> Properties -> C/C++ General -> Preprocessor Include Paths, Macros etc. -> Providers확인하십시오 Enable language settings providers for this project.

  • Eclipse를 다시 시작하십시오.

바라건대 그것은 이미 트릭을 수행합니다.


MinGW 및 gcc 4.8.1을 사용하는 Eclipse의 * std :: shared_ptr *에서 비슷한 문제가 발생했습니다. 어쨌든 Eclipse는 * shared_ptr *를 확인하지 않습니다. 이 문제를 해결하기 위해 C ++ 기호에 __cplusplus 매크로를 수동으로 추가했습니다. -Eclipse에서 찾을 수 있습니다. -std = c ++ 11 을 컴파일 옵션으로 지정했기 때문에 I (ahem)는 Eclipse 코드 분석기도 해당 옵션을 사용할 것이라고 가정했습니다. 따라서이를 수정하려면 :

  1. 프로젝트 컨텍스트-> C / C ++ 일반-> 경로 및 기호-> 기호 탭
  2. 언어 패널에서 C ++를 선택합니다.
  3. 값이 201103 인 __cplusplus 기호를 추가합니다 .

이것의 유일한 문제는 gcc가 심볼이 이미 정의되어 있다고 불평하지만 (!) 컴파일은 이전과 같이 완료된다는 것입니다.


For me it helped to enable the automated discovery in Properties -> C/C++-Build -> Discovery Options to resolve this problem.


I simply delete all error in the buttom: problem list. then close project and reopen project clean project build all run

then those stupids errors go.


If all else fails, like it did in my case, then just disable annotations. I started a c++11 project with own makefile but couldn't fix all the problems. Even if you disable annotations, eclipse will still be able to help you do some autocompletion. Most importantly, the debugger still works!


I had the same issue using Eclipse CDT (Kepler) on Windows with Cygwin installed. After pointing the project properties at every Cygwin include I could think of, it still couldn't find cout.

The final missing piece turned out to be C:cygwin64\lib\gcc\x86_64-pc-cygwin\4.8.2\install-tool\include.

To sum up:

  • Right click on the project
  • Choose Properties
  • Navigate to C/C++ General > Paths and Symbols > Includes tab
  • Click Add...
  • Click File system...
  • Browse to the location of your Cygwin lib\gcc\x86_64-pc-cygwin\4.8.2\install-tool\include
  • Click OK

Here is what my project includes ended up looking like when it was all said and done: enter image description here


You guys are looking under the wrong section. I realized the difference when I installed in Linux after recently getting frustrated with Windows and the difference was immediately apparent.

In the new setup I have an includes folder in a projected that I created out of existing source. I can expand this and see a ton of includes; however, I cannot add to them. This lead me to a hunt for where these files were being listed.

They're listed under the Project Properties > C/C++ General > Preprocessor Includes > GNU C++ CDT GCC Built-in Compiler Settings [Shared] Under that is a ton of includes.

These settings are set by the toolchain you've selected.


I have created the Makefile project using cmake on Ubuntu 16.04.

When created the eclipse project for the Makefiles which cmake generated I created the new project like so:

File --> new --> Makefile project with existing code.

Only after couple of times doing that I have noticed that the default setting for the "Toolchain for indexer settings" is none. In my case I have changed it to Linux GCC and all the errors disappeared.

Hope it helps and let me know if it is not a legit solution.

Cheers,

Guy.


Just adding yet another bit of advice after trying a bunch of stuff myself and it not working....

I had GCC installed and the path to the includes set correctly. Had the std error as well, and couldn't get anything working for cout (and I suspect anything in the SL...)

Took me awhile to realize that g++ wasn't installed - gcc was but not g++. So just do:

sudo apt-get install g++

Restart eclipse. Assuming above mentioned details about gcc & paths to includes are fine, you should be okay now...


I had this happen after updating gcc and eclipse on ArchLinux. What solved it for me was Project -> C/C++ Index -> Rebuild.


mine was bit easy to fig out right click >run as>run configration

check boxes include system lib,inherited mains

참고URL : https://stackoverflow.com/questions/10803685/eclipse-cdt-symbol-cout-could-not-be-resolved

반응형