본문 바로가기

Mac

OSX에서 Linux용 GCC를 cross-compile로 사용하기

아래 주소에서 최신 gcc 버전을 다운 받는다.

현재 블로그를 작성하는 동안에 gcc-4.8.1-for-linux64.dmg (92.4 MB)를 설치했다.

http://crossgcc.rts-software.org/doku.php?id=compiling_for_linux


GCC 4.8.1

Theses packages have been built with BINUTILS 2.23.2, GCC 4.8.1, GMP 4.3.2, MPC 0.8.1, MPFR 2.4.2 and GLIBC 2.11.1, for Mac OS X 10.6 and later.

32-Bit Linux Binaries for Mac Intel

Version Compilers Installer to download Installation directory 
6 (october 2013) C, C++ gcc-4.8.1-for-linux32.dmg (84.4 MB)/usr/local/gcc-4.8.1-for-linux32/

64-Bit Linux Binaries for Mac Intel

Version Compilers Installer to download Installation directory 
6 (october 2013) C, C++ gcc-4.8.1-for-linux64.dmg (92.4 MB)/usr/local/gcc-4.8.1-for-linux64/

Build scripts for Mac Intel

Version Package 
6 (october 2013) gcc-4.8.1-for-linux32-linux64.tbz (42.3 MB)


다운받아서 설치하치하면 /usr/local/gcc-4.8.1-for-linux64/ 경로에 설치된다.

이제 alias를 설정해 놓고, 리눅스용으로 빌드할 수 있다.

vi를 이용해서 /etc/bashrc를 열어서 다음처럼 설정을 하자규~~


1. env파일(~/Documents/Develop/config/x86_64-pc-linux-cross-compile.env)을 하나 만들고 gcc가 설치된 곳을 PATH에 추가해준다.

#!bin/sh

export PATH="/usr/local/gcc-4.8.1-for-linux64/bin:$PATH"


2. ~/.profile를 만들고 다음을 추가하자.

# x86_64-PC-Linux cross-compiler

alias SET_ENV_X86_64_PC_LINUX='source /Users/erato/Documents/Develop/config/x86_64-pc-linux-cross-compile.env'


3. 터미널을 새로 열고 SET_ENV_X86_64-PC-LINUX를 입력하면 x86 gcc를 사용할 수 있다.