
--without-PACKAGE 옵션은 g++ 컴파일러에 내장된 옵션이며, C++ 표준 라이브러리의 특정 패키지를 포함하지 않도록 컴파일러에 명령합니다.
이 옵션을 사용하면, std::iostream, std::vector, std::string, std::algorithm 등과 같은 표준 라이브러리 패키지를 포함하지 않습니다.
예를 들어, 다음 코드에서 --without-PACKAGE 옵션을 사용하면, std::cout을 사용할 수 없습니다.
#hostingforum.kr
cpp
#include
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
위 코드를 컴파일할 때 --without-PACKAGE 옵션을 사용하면, 컴파일러는 std::cout을 사용할 수 없다고 오류를 발생시킵니다.
#hostingforum.kr
bash
g++ --without-PACKAGE test.cpp -o test
위 코드를 컴파일할 때 오류가 발생합니다.
#hostingforum.kr
bash
test.cpp: In function 'int main()':
test.cpp:3:12: error: 'std::cout' is not a member of 'std'
3 | std::cout << "Hello, World!" << std::endl;
| ^~~~~~~~
test.cpp:3:12: note: 'std' used without knowledge of what it refers to
3 | std::cout << "Hello, World!" << std::endl;
| ^~~~~~~~
이러한 오류를 피하기 위해, 필요한 표준 라이브러리 패키지를 포함하도록 컴파일러에 명령할 수 있습니다.
#hostingforum.kr
bash
g++ test.cpp -o test
위 코드를 컴파일하면, 오류가 발생하지 않습니다.
#hostingforum.kr
bash
g++ test.cpp -o test
위 코드를 컴파일할 때, 컴파일러는 std::cout을 사용할 수 있습니다.
2025-06-25 05:04