게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
gcc precompiled header 테스트 결과
게시물ID : programmer_12442짧은주소 복사하기
작성자 : 구차니
추천 : 0
조회수 : 704회
댓글수 : 0개
등록시간 : 2015/07/30 10:13:58
여러가지 조언을 주신 여러분들에게 감사의 말씀을 드립니다.
귀찮아서 블로그에 정리한거 복/붙 합니다.



----


-c -o gch를 통해서 gcc precompiled header를 생성이 가능하다.

물론 gch가 생성되면 원래 헤더파일이 사라져도 문제없이 컴파일 된다.

pi@raspberrypi ~/src/pch $ g++ -c stdafx.h -o stdafx.h.gch


pi@raspberrypi ~/src/pch $ ls -al

합계 4244

drwxr-xr-x 2 pi pi    4096  7월 30 00:58 .

drwxr-xr-x 9 pi pi    4096  7월 30 00:58 ..

-rw-r--r-- 1 pi pi      37  7월 30 00:58 1

-rw-r--r-- 1 pi pi      91  7월 30 00:58 a.cpp

-rw-r--r-- 1 pi pi      37  7월 30 00:58 stdafx.h

-rw-r--r-- 1 pi pi 4324036  7월 30 00:59 stdafx.h.gch


pi@raspberrypi ~/src/pch $ file stdafx.h.gch

stdafx.h.gch: GCC precompiled header (version 013) for C++


pi@raspberrypi ~/src/pch $ mv stdafx.h stdafx.h.bak

pi@raspberrypi ~/src/pch $ g++ a.cpp 


확장자 gch로 확인하기 때문에 다른 확장자로 변경시 gch 헤더를 찾지 못한다.

pi@raspberrypi ~/src/pch $ mv stdafx.h.gch stdafx.h.gch.bak

pi@raspberrypi ~/src/pch $ ls -al

합계 4248

drwxr-xr-x 2 pi pi    4096  7월 30 01:01 .

drwxr-xr-x 9 pi pi    4096  7월 30 00:58 ..

-rw-r--r-- 1 pi pi      91  7월 30 00:58 a.cpp

-rwxr-xr-x 1 pi pi    6492  7월 30 01:00 a.out

-rw-r--r-- 1 pi pi      37  7월 30 00:58 stdafx.h.bak

-rw-r--r-- 1 pi pi 4324036  7월 30 00:59 stdafx.h.gch.bak

pi@raspberrypi ~/src/pch $ g++ a.cpp

a.cpp:1:20: fatal error: stdafx.h: 그런 파일이나 디렉터리가 없습니다

compilation terminated.


-c가 좀더 간편한듯.

-x c++-hedaer

-x c-header는 너무 길어 -_-

pi@raspberrypi ~/src/pch $ gcc -x c++-header stdafx.h -o stdafx.h.gch

pi@raspberrypi ~/src/pch $ ls -al

합계 4248

drwxr-xr-x 2 pi pi    4096  7월 30 01:01 .

drwxr-xr-x 9 pi pi    4096  7월 30 00:58 ..

-rw-r--r-- 1 pi pi      91  7월 30 00:58 a.cpp

-rwxr-xr-x 1 pi pi    6492  7월 30 01:00 a.out

-rw-r--r-- 1 pi pi      37  7월 30 00:58 stdafx.h

-rw-r--r-- 1 pi pi 4324036  7월 30 01:01 stdafx.h.gch  


-c는 찾는거 포기 -_-

-x language

Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on the file name suffix). This option applies to all following input files until the next -x option. Possible values for language are:

c  c-header  c-cpp-output

c++  c++-header  c++-cpp-output

objective-c  objective-c-header  objective-c-cpp-output

objective-c++ objective-c++-header objective-c++-cpp-output

assembler  assembler-with-cpp

ada

f77  f77-cpp-input f95  f95-cpp-input

java


-o file

Place output in file file. This applies regardless to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.

If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.

[링크 : http://linux.die.net/man/1/gcc] 


췟 이건 안되네 -_-

pi@raspberrypi ~/src/pch $ gcc stdafx.h -o stdafx.h.gch

stdafx.h:1:18: fatal error: string: 그런 파일이나 디렉터리가 없습니다

compilation terminated. 



결론 -c -o .gch로 하자

출처 http://minimonk.net/5673
꼬릿말 보기
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호