오류정리

VScode :: undefined reference to `pcap_close' 애러 해결

한별글명 2022. 1. 8. 20:19

tasks.json 파일에 "-lpcap" 내용을 추가하면 된다.

 

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C++ 빌드",
			"command": "/usr/bin/g++-10",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				"-o",
				"${fileDirname}/${fileBasenameNoExtension}",
			],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": "build",
			"detail": "컴파일러: /usr/bin/g++-10"
		}
	]
}

위에는 기본 tasks.json 설정이다

 

"args" 의 "${fileDirname}/${fileBasenameNoExtension}",  아래에 "-lpcap" 을 작성하자.

 

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C++ 빌드",
			"command": "/usr/bin/g++-10",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				"-o",
				"${fileDirname}/${fileBasenameNoExtension}",
				"-lpcap"
			],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": "build",
			"detail": "컴파일러: /usr/bin/g++-10"
		}
	]
}

이렇게만 해주면 끝.

 

오류 후 "-lpcap" 추가 후 빌드 결과