Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)

Visual Studio 2019 - 리눅스 C/C++ 프로젝트에 인텔리센스가 동작하지 않는 경우

인텔리센스가 동작하지 않는 주요 원인은 "#include" 헤더 파일을 가져오지 못해서입니다. 그래서 대부분의 헤더 파일에 대해 "빨간색 밑줄"이 그어지고,

File 'stdio.h' not found in current source file's directory or in build system paths.
cannot open sourece file "stdio.h"

라는 식의 메시지를 볼 수 있습니다. 비주얼 스튜디오의 내부 동작은 알 수 없지만, 어쨌든 중요한 것은 그것이 동작하지 못하고 있으므로 이런 경우에는 약간의 수작업을 해야 합니다.

가장 먼저 할 일은, 해당 리눅스의 헤더 파일들을 가져와야 합니다. 이것은 Visual Studio에서 "Tools" / "Options"의 "Cross Platform" / "Connection Manager" / "Remote Headers IntelliSense Manager"를 통해 SSH 연결을 설정해 두면,

ftdi_raspberrypi_3.png

자동으로 다음의 경로에 다운로드하므로,

%LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0

그 외 다른 작업을 할 필요는 없습니다. 또한, 리눅스 배포본이 비슷하다면 기존에 다운로드한 헤더 파일들을 이용해도 크게 무리는 없습니다. 제 경우에 WSL에 연결해 둔 SSH 설정이 있어서 다음과 같은 디렉터리에 헤더 파일이 이미 캐시가 되었습니다.

%LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\-1253123614\usr

원래는 비주얼 스튜디오에서 이 상태만 되어도 자연스럽게 헤더 파일들을 인텔리센스에서 열람해야 하는데 여전히 소스 코드에는 빨간 줄이 그어져 동작하지 않을 수 있습니다.

wsl_intellisense_1.png

그렇다면 이제 수작업으로 리눅스 C/C++ 프로젝트에 HeaderCache 폴더를 등록해 주면 됩니다. 가령 제 경우에는, "Configuration Properties" / "VC++ Directories"에 다음과 같은 순서로 폴더를 등록했습니다.

%LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\-1253123614\usr\include\x86_64-linux-gnu
%LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\-1253123614\usr\include\x86_64-linux-gnu\c++\5.4.0
%LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\-1253123614\usr\include\c++\5.4.0
%LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\-1253123614\usr\include
%LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\-1253123614\usr\include\linux
%LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\-1253123614\usr\include\c++\5.4.0\tr1

설정 후 잠시 기다리면 정상적으로 모든 빨간색 줄이 사라지면서 인텔리센스가 정상적으로 동작하는 것을 볼 수 있습니다.




참고로, WSL에도 "Remote Headers IntelliSense Manager"를 통해 SSH 연결을 하면 WSL 측의 헤더 파일을 다운로드할 수 있습니다. 단지 문제는, 기본 WSL 환경의 경우 ssh 데몬을 실행 상태로 두지 않기 때문에,

c:\temp> netstat -ano | findstr :22

c:\temp> 

헤더 파일을 받아올 리눅스 배포본 shell에서 직접 실행해야 합니다.

$ sudo /etc/init.d/ssh start
 * Starting OpenBSD Secure Shell server sshd

c:\temp> netstat -ano | findstr :22
  TCP    0.0.0.0:22             0.0.0.0:0              LISTENING       2420
  TCP    [::]:22                [::]:0                 LISTENING       2420

c:\temp> 

그런 다음 다시 "Remote Headers IntelliSense Manager"를 이용해 SSH 연결을 하면 헤더 파일들을 자동으로 다운로드해 로컬에 cache합니다.




마지막으로, Visual Studio의 "Error List" 창의 "Build + IntelliSense" 보기에는 여전히 다음과 같은 식의 인텔리센스 오류가 보고됩니다.

Error (active) E0020 identifier "__gnuc_va_list" is undefined ConsoleApplication1 %LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\409410665\usr\include\wchar.h  600 

Error (active) E2870 128-bit floating-point types are not supported in this configuration ConsoleApplication1 %LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\409410665\usr\include\x86_64-linux-gnu\bits\floatn.h   75  

검색해 보면, 이 부분은 어쨌든 인텔리센스를 위한 컴파일러는 로컬 컴퓨터의 Visual C++이기 때문에 리눅스 쪽과 맞지 않는 부분이 있어서라고 합니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 5/23/2019]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 61  62  63  64  65  66  67  68  69  70  71  [72]  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
11842정성태3/13/201910262개발 환경 구성: 433. 마이크로소프트의 CoreCLR 프로파일러 예제를 Visual Studio CMake로 빌드하는 방법 [1]파일 다운로드1
11841정성태3/13/201910226VS.NET IDE: 132. Visual Studio 2019 - CMake의 컴파일러를 기본 g++에서 clang++로 변경
11840정성태3/13/201911334오류 유형: 526. 윈도우 10 Ubuntu App 환경에서는 USB 외장 하드 접근 불가
11839정성태3/12/201914081디버깅 기술: 124. .NET Core 웹 앱을 호스팅하는 Azure App Services의 프로세스 메모리 덤프 및 windbg 분석 개요 [3]
11838정성태3/7/201916838.NET Framework: 811. (번역글) .NET Internals Cookbook Part 1 - Exceptions, filters and corrupted processes [1]파일 다운로드1
11837정성태3/6/201926534기타: 74. 도서: 시작하세요! C# 7.3 프로그래밍 [10]
11836정성태3/5/201914379오류 유형: 525. Visual Studio 2019 Preview 4/RC - C# 8.0 Missing compiler required member 'System.Range..ctor' [1]
11835정성태3/5/201914140.NET Framework: 810. C# 8.0의 Index/Range 연산자를 .NET Framework에서 사용하는 방법 및 비동기 스트림의 컴파일 방법 [3]파일 다운로드1
11834정성태3/4/201913033개발 환경 구성: 432. Visual Studio 없이 최신 C# (8.0) 컴파일러를 사용하는 방법
11833정성태3/4/201913786개발 환경 구성: 431. Visual Studio 2019 - CMake를 이용한 공유/실행(so/out) 리눅스 프로젝트 설정파일 다운로드1
11832정성태3/4/201910824오류 유형: 524. Visual Studio CMake - rsync: connection unexpectedly closed
11831정성태3/4/201910432오류 유형: 523. Visual Studio 2019 - 새 창으로 뜬 윈도우를 닫을 때 비정상 종료
11830정성태2/26/201910237오류 유형: 522. 이벤트 로그 - Error opening event log file State. Log will not be processed. Return code from OpenEventLog is 87.
11829정성태2/26/201912136개발 환경 구성: 430. 마이크로소프트의 CoreCLR 프로파일러 예제 빌드 방법 - 리눅스 환경 [1]
11828정성태2/26/201918522개발 환경 구성: 429. Component Services 관리자의 RuntimeBroker 설정이 2개 있는 경우 [8]
11827정성태2/26/201912401오류 유형: 521. Visual Studio - Could not start the 'rsync' command on the remote host, please install it using your system package manager.
11826정성태2/26/201912282오류 유형: 520. 우분투에 .NET Core SDK 설치 시 패키지 의존성 오류
11825정성태2/25/201917176개발 환경 구성: 428. Visual Studio 2019 - CMake를 이용한 리눅스 빌드 환경 설정 [1]
11824정성태2/25/201911981오류 유형: 519. The SNMP Service encountered an error while accessing the registry key SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration. [1]
11823정성태2/21/201913470오류 유형: 518. IIS 관리 콘솔이 뜨지 않는 문제
11822정성태2/20/201911597오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우
11821정성태2/20/201912075오류 유형: 516. Visual Studio 2019 - This extension uses deprecated APIs and is at risk of not functioning in a future VS update. [1]
11820정성태2/20/201915208오류 유형: 515. 윈도우 10 1809 업데이트 후 "User Profiles Service" 1534 경고 발생
11819정성태2/20/201913870Windows: 158. 컴퓨터와 사용자의 SID(security identifier) 확인 방법
11818정성태2/20/201912786VS.NET IDE: 131. Visual Studio 2019 Preview의 닷넷 프로젝트 빌드가 20초 이상 걸리는 경우 [2]
11817정성태2/17/20199955오류 유형: 514. WinDbg Preview 실행 오류 - Error : DbgX.dll : WindowsDebugger.WindowsDebuggerException: Could not load dbgeng.dll
... 61  62  63  64  65  66  67  68  69  70  71  [72]  73  74  75  ...