Differences between revisions 4 and 5
Revision 4 as of 2012-08-14 14:45:32
Size: 1179
Editor: 182
Comment:
Revision 5 as of 2013-02-14 13:40:54
Size: 1282
Editor: 61
Comment:
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
 * [[http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3|HOWTO fix -fPIC errors]]

GnuCompilerCollection

GNU Cee / C++ Compiler

http://gcc.gnu.org

각종자료


일반적인 사용법

$ gcc -g -Wall -ohello hello.c

옵션들

  • -o : 출력파일명을 정한다.
  • -c : 컴파일만한다. .o파일 생성
  • -I : 헤더파일위치 지정. 보통은 ""을 기준으로한다. -Iinclude 하면 현재 디렉토리의 include디렉토리
  • -l : 사용하는 라이브러리. libmylib.a 이면 -lmylib 이라고 쓴다.
  • -L : 라이브러리의 위치

라이브러리만드는법

 $ gcc -c myfunc.c
 $ ar r libmylib.a myfunc.o
 $ ar s libmylib.a
 $ ar t libmylib.a
 myfunc.o
 $ gcc -o say_linux hello.c -lmylib

64bit용으로 컴파일하기 옵션

CC=gcc CFLAGS="-O3 -m64 -fno-omit-frame-pointer" CXX=gcc 
CXXFLAGS="-O3 -m64 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"

Debugging은 주로 GDB 에서 한다.


SeeAlso GCC, CeeCompiler


CategoryProgram

GCC (last edited 2013-02-14 13:45:41 by 61)

web biohackers.net