Homebrew 설치기 - 2

2014. 1. 3. 23:00 from Code

http://brew.sh


http://spaghetticoder.tistory.com/entry/Build-and-using-glib-in-Mac-os-failed

http://spaghetticoder.tistory.com/entry/Homebrew-설치기-1


자.. 이제 Homebrew 를 설치해보자.

위 링크에 가면 맨 아래쪽에 왠 ruby 명령어가 있다.

그대로 복사하며 터미널에 붙여 넣고 enter.


sanchoui-MacBook-Air:~ sancho$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

==> This script will install:

/usr/local/bin/brew

/usr/local/Library/...

/usr/local/share/man/man1/brew.1


Press ENTER to continue or any other key to abort

==> /usr/bin/sudo /bin/mkdir /usr/local


WARNING: Improper use of the sudo command could lead to data loss

or the deletion of important system files. Please double-check your

typing when using sudo. Type "man sudo" for more information.


To proceed, enter your password, or type Ctrl-C to abort.


Password:

==> /usr/bin/sudo /bin/chmod g+rwx /usr/local

==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local

==> Installing the Command Line Tools (expect a GUI popup):

==> /usr/bin/sudo /usr/bin/xcode-select --install

xcode-select: note: install requested for command line developer tools

Press any key when the installation has completed.


그러면 xcode command line tool 이 설치되어 있지 않았다고 하면서 설치하라고 창이 뜬다.

가볍게 설치 버튼 누르고 계속 진행한다.


==> Downloading and installing Homebrew...

remote: Counting objects: 144698, done.

remote: Compressing objects: 100% (47500/47500), done.

Receiving objects:  42% (61625/144698), 11.97 MiB | 76.00 KiB/s   


그럼 왠 git repository 를 clone 하기 시작한다. 이거 뭐야 무서워..

약 3~4분 후에 완료되고 아래와 같이 나온다.


==> Downloading and installing Homebrew...

remote: Counting objects: 144698, done.

remote: Compressing objects: 100% (47500/47500), done.

remote: Total 144698 (delta 102505), reused 137250 (delta 96133)

Receiving objects: 100% (144698/144698), 21.46 MiB | 346.00 KiB/s, done.

Resolving deltas: 100% (102505/102505), done.

From https://github.com/Homebrew/homebrew

 * [new branch]      master     -> origin/master

HEAD is now at 745311b pyqt: patch handling of qmake inline comments.

==> Installation successful!

You should run `brew doctor' *before* you install anything.

Now type: brew help

sanchoui-MacBook-Air:~ sancho$ 


Installation successful?? 벌써 끝이란 말인가...

아무거나 install 하지말고 먼저 brew doctor 를 실행하란다. brew help 도 실행해보고.

brew help 부터 해볼까나.


sanchoui-MacBook-Air:~ sancho$ brew help

Example usage:

  brew [info | home | options ] [FORMULA...]

  brew install FORMULA...

  brew uninstall FORMULA...

  brew search [foo]

  brew list [FORMULA...]

  brew update

  brew upgrade [FORMULA...]

  brew pin/unpin [FORMULA...]


Troubleshooting:

  brew doctor

  brew install -vd FORMULA

  brew [--env | --config]


Brewing:

  brew create [URL [--no-fetch]]

  brew edit [FORMULA...]

  open https://github.com/Homebrew/homebrew/wiki/Formula-Cookbook


Further help:

  man brew

  brew home


여기서 FORMULA 라고 하는것은 brew 가 관리할 package name 이라고 보면 된다.

brew install/uninstall 은 FORMULA 설치 및 삭제로 보이고..
brew search 는 brew를 통해 설치 가능한 FORMULA 검색,
brew list 는 현재 설치된 FORMULA 리스팅???
brew update 는 homebrew 자체를 update 하는 것으로 보이고..
brew upgrade 는 FORMULA 를 update 하는 것 처럼 보인다.

이정도만 알아도 뭐 사용하는데는 문제 없어 보인다.
install 하기 전에 brew doctor 를 실행하라고 신신당부 하였으니 brew doctor 를 실행해 보자.

sanchoui-MacBook-Air:~ sancho$ brew doctor

Your system is ready to brew.

sanchoui-MacBook-Air:~ sancho$ 


나의 시스템은 brew를 사용할 준비가 되었단다.

자.. 이제 그럼 숙원 사업인 glib를 설치해보자 ㅠㅠ
일단 brew search 명령으로 glib을 검색해 보자.

sanchoui-MacBook-Air:~ sancho$ brew search glib

dbus-glib glib   glib-networking  glibmm     json-glib     taglib

sanchoui-MacBook-Air:~ sancho$ 


2번째에 애증의 glib이 보인다. brew install 명령으로 설치해주자.


sanchoui-MacBook-Air:~ sancho$ brew install glib

==> Installing dependencies for glib: xz, pkg-config, gettext, libffi

==> Installing glib dependency: xz

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/xz-5.0.5.mavericks.bottle.2.tar.gz

######################################################################## 100.0%

==> Pouring xz-5.0.5.mavericks.bottle.2.tar.gz

   /usr/local/Cellar/xz/5.0.5: 58 files, 1.5M

==> Installing glib dependency: pkg-config

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.28.mavericks.bottle.2.tar.gz

######################################################################## 100.0%

==> Pouring pkg-config-0.28.mavericks.bottle.2.tar.gz

   /usr/local/Cellar/pkg-config/0.28: 10 files, 604K

==> Installing glib dependency: gettext

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gettext-0.18.3.1.mavericks.bottle.1.tar.gz

######################################################################## 100.0%

==> Pouring gettext-0.18.3.1.mavericks.bottle.1.tar.gz

==> Caveats

This formula is keg-only, so it was not symlinked into /usr/local.


OS X provides the BSD gettext library and some software gets confused if both are in the library path.


Generally there are no consequences of this for you. If you build your

own software and it requires this formula, you'll need to add to your

build variables:


    LDFLAGS:  -L/usr/local/opt/gettext/lib

    CPPFLAGS: -I/usr/local/opt/gettext/include


==> Summary

   /usr/local/Cellar/gettext/0.18.3.1: 374 files, 12M

==> Installing glib dependency: libffi

==> Downloading http://mirrors.kernel.org/sources.redhat.com/libffi/libffi-3.0.13.tar.gz

######################################################################## 100.0%

==> ./configure --prefix=/usr/local/Cellar/libffi/3.0.13

==> make install

==> Caveats

This formula is keg-only, so it was not symlinked into /usr/local.


Mac OS X already provides this software and installing another version in

parallel can cause all kinds of trouble.


Some formulae require a newer version of libffi.


Generally there are no consequences of this for you. If you build your

own software and it requires this formula, you'll need to add to your

build variables:


    LDFLAGS:  -L/usr/local/opt/libffi/lib


==> Summary

   /usr/local/Cellar/libffi/3.0.13: 13 files, 388K, built in 14 seconds


이 ㅅㅂ.. 내가 삽질한 작업들을 모두 자동으로.. 성공적으로 수행해 준다.

dependency 있는 library 들을 자동으로 찾아서 소스 다운받고 컴파일 하고 설치한다.. brew 짱짱맨 ㅠㅠ


==> Installing glib

==> Downloading http://ftp.gnome.org/pub/gnome/sources/glib/2.38/glib-2.38.2.tar.xz

######################################################################## 100.0%

==> Downloading patches

######################################################################## 100.0%

######################################################################## 100.0%

==> Patching

patching file aclocal.m4

Hunk #1 succeeded at 1580 (offset 15 lines).

patching file config.h.in

patching file configure

Hunk #2 succeeded at 27737 (offset 41 lines).

patching file configure.ac

Hunk #1 succeeded at 2683 (offset 1 line).

patching file gio/gdbusprivate.c

patching file gio/xdgmime/xdgmime.c

patching file gio/Makefile.am

patching file gio/Makefile.in

patching file gio/gnextstepsettingsbackend.c

patching file gio/gnextstepsettingsbackend.m

==> ./configure --disable-maintainer-mode --disable-silent-rules --disable-dtrace --disable-libelf --prefix=/usr/local/Cellar/glib/2.38.2 --localstatedir=/usr/local/var --with-gio-module-dir=/usr/local/li

==> make

==> make install

   /usr/local/Cellar/glib/2.38.2: 413 files, 17M, built in 99 seconds


dependency library 설치가 끝나고 애증의 glib 을 설치하기 시작한다.

허허 이렇게 간단할 줄이야.. 99초 걸렸단다. 99초.


자 그럼 간단히 hello 소스를 작성하고 실제로 glib을 링크 시켜 보자앗.


1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
#include <glib.h>
 
int main(int c, char **v)
{
    char *str = NULL;
    
    str = g_strdup("Hello world!");
    printf("%s\n", str);
 
    return 0;
}


간단히 g_strdup 이용해서 우리의 친구 Hello world 를 strdup 하고 출력한다.

pkg-config 도 설치 되었으니 pkg-config 이용해서 컴파일 해보자.


sanchoui-MacBook-Air:glib_test sancho$ gcc `pkg-config --cflags --libs glib-2.0` hello.c

sanchoui-MacBook-Air:glib_test sancho$ ./a.out 

Hello world!


굿 잡! 성공이다~!


오픈 소스를 받아서 직접 컴파일 하기란 쉽지가 않다.

아무리 dependency 라이브러리들이 명시가 되어있어도 하나하나 검색해서 소스 다운 받고 컴파일 하고.. 킹왕짱 노가다 작업이다.

우분투를 사용했을적에는 거긴 시스템이 워낙 잘되어 있으니.. 왠만한건 모두 패키징 되어 있고 받아다가 간단히 사용할 수 있다.

mac에서도 비슷한 녀석을 찾아서 다행이다. 



'Code' 카테고리의 다른 글

dbus - 2  (0) 2014.01.23
dbus - 1  (0) 2014.01.15
Homebrew 설치기 - 1  (0) 2014.01.02
Build and using glib in Mac os - failed!  (0) 2014.01.02
bash shell script #1  (0) 2013.12.01
Posted by 스파게티코더 :

Homebrew 설치기 - 1

2014. 1. 2. 22:05 from Code

나의 맥북에서 glib 빌드 실패 이후 생각해 보았다.

(http://spaghetticoder.tistory.com/entry/Build-and-using-glib-in-Mac-os-failed)

(솔직히 말하면 작성중이었던 실패기 - 쓰던 시각에는 실패기가 아니었다 - 를 짜증이 이빠이 나서 날려버리려고 하였으나,

실패의 기록도 기록이기에 남겨두었다. 괜히 영어로 썼다)


과연 macosx 에는 이런 dependecy 를 자동으로 관리해주고 이미 빌드되어 있는 녀석들을 제공해 주는,

말하자면 패키지 관리자(우분투, 데비안의 dpkg 처럼)는 없는지.


찾아보니 과연 있다. 유명한 녀석들이 3개쯤 보인다.


http://brew.sh

http://www.macports.org

http://www.finkproject.org


각각의 장단점이 있겠지만, 면밀한 조사 끝에 homebrew 를 설치하기로 했다.


처음엔 macport 를 설치하려 했지만 macport는 dependency package 들 중에, 

그것이 현재 platform 에 설치되어 있어도 지 맘대로 지 서버에서 가져와서 설치한단다.

그러면 나의 실패기와 무엇이 다르단 말인가.. library 버전 안맞아서 부팅도 안되는 상황이 또 발생할 수 있다.


Homebrew 홈페이지 가보니 xcode와 xcode command line utility 가 필요한 듯 보인다.

맥북을 초기화 하였으므로 이전에 설치했던 녀석들이 모조리 날아갔다. 다시 xcode 설치해야한다.


귀찮다.. 설치 걸어두고 자야겠다. 피곤하다.

본격적인 설치기는 2편에서.. 


'Code' 카테고리의 다른 글

dbus - 2  (0) 2014.01.23
dbus - 1  (0) 2014.01.15
Homebrew 설치기 - 2  (0) 2014.01.03
Build and using glib in Mac os - failed!  (0) 2014.01.02
bash shell script #1  (0) 2013.12.01
Posted by 스파게티코더 :

Reference - https://developer.gnome.org/glib/stable/glib-building.html


1. Downloading glib code.

http://ftp.gnome.org/pub/gnome/sources/glib/


2. Extract the archive and run ./configure

sanchoui-MacBook-Air:glib-2.39.2 sancho$ ./configure

....

configure: error: in `/Users/sancho/Downloads/glib-2.39.2':

configure: error: The pkg-config script could not be found or is too old.  Make sure it

is in your PATH or set the PKG_CONFIG environment variable to the full

path to pkg-config.


Alternatively, you may set the environment variables LIBFFI_CFLAGS

and LIBFFI_LIBS to avoid the need to call pkg-config.

See the pkg-config man page for more details.


To get pkg-config, see <http://pkg-config.freedesktop.org/>.

See `config.log' for more details


There is no pkg-config.. we need to find and install it.



2-1. Download pkg-config code and install


http://www.freedesktop.org/wiki/Software/pkg-config/

http://pkgconfig.freedesktop.org/releases/


sanchoui-MacBook-Air:pkg-config-0.28 sancho$ ./configure 

...

checking for GLIB... no

configure: error: Either a previously installed pkg-config or "glib-2.0 >= 2.16" could not be found. Please set GLIB_CFLAGS and GLIB_LIBS to the correct values or pass --with-internal-glib to configure to use the bundled copy.


shit.. we should use the glib in pkg-config source internally to build it. 

sanchoui-MacBook-Air:pkg-config-0.28 sancho$ ./configure --with-internal-glib

sanchoui-MacBook-Air:pkg-config-0.28 sancho$ make

sanchoui-MacBook-Air:pkg-config-0.28 sancho$ sudo make install

sanchoui-MacBook-Air:pkg-config-0.28 sancho$ pkg-config 

Must specify package names on the command line


success.. let's retry ./configure in glib source directory.

sanchoui-MacBook-Air:glib-2.39.2 sancho$ ./configure

...

checking for LIBFFI... no

configure: error: Package requirements (libffi >= 3.0.0) were not met:


No package 'libffi' found


shit...... what the libffi???
I don't know it even if read below link but we should install it to build fucking glib.


2-2. Download libffi code and install


http://sourceware.org/libffi/


sanchoui-MacBook-Air:libffi-3.0.13 sancho$ ./configure

sanchoui-MacBook-Air:libffi-3.0.13 sancho$ make

sanchoui-MacBook-Air:libffi-3.0.13 sancho$ sudo make install


success without any exception! let's retry again ./configure in glib source directory..

sanchoui-MacBook-Air:glib-2.39.2 sancho$ ./configure 

...

configure: error: 

*** You must have either have gettext support in your C library, or use the

*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html


fucking gettext.. go to the above link and download the source and build and install it.

2-3. Download gettext and install


sanchoui-MacBook-Air:gettext-0.18.3.1 sancho$ ./configure 

sanchoui-MacBook-Air:gettext-0.18.3.1 sancho$ make

sanchoui-MacBook-Air:gettext-0.18.3.1 sancho$ sudo make install


Good. Fortunately, success without any error. If it is, I would stop this fucking build!

Let's retry again ./configure in glib source directory :)

sanchoui-MacBook-Air:glib-2.39.2 sancho$ ./configure 

...

checking for libintl.h... no

configure: error: 

*** You must have either have gettext support in your C library, or use the

*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html


fuck!!!! I installed it!!!!! hmm.. what's the problem? Once, I checked the location of libintl.h

sanchoui-MacBook-Air:glib-2.39.2 sancho$ find /usr -name "libintl.h"

/usr/local/include/libintl.h

find: /usr/sbin/authserver: Permission denied


It is in /usr/local/include. Once, I checked the config.log and found the problem like below.

 639 configure:7963: checking libintl.h usability

 640 configure:7963: gcc -c -g -O2  conftest.c >&5

 641 conftest.c:66:10: fatal error: 'libintl.h' file not found

 642 #include <libintl.h>

 643          ^

 644 1 error generated.

 645 configure:7963: $? = 1


shit.... this stupid configure script operated the gcc without -I option.
hmm.. remove the gettext installed just before and install newly with prefix /usr.

sanchoui-MacBook-Air:gettext-0.18.3.1 sancho$ ./configure --prefix=/usr

sanchoui-MacBook-Air:gettext-0.18.3.1 sancho$ make

sanchoui-MacBook-Air:gettext-0.18.3.1 sancho$ sudo make install


I checked the libintl.h in /usr/include.

sanchoui-MacBook-Air:gettext-0.18.3.1 sancho$ ls -al /usr/include/libintl.h 

-rw-r--r--  1 root  wheel  16654 12 31 22:34 /usr/include/libintl.h


Ok, let's retry ./configure again in glib source directory.

sanchoui-MacBook-Air:glib-2.39.2 sancho$ ./configure 

...

checking for libintl.h... no

configure: error: 

*** You must have either have gettext support in your C library, or use the

*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html


failed...... :( what's the problem? default include path?

I set the default include path like below and retry configure.

sanchoui-MacBook-Air:Downloads sancho$ declare -x C_INCLUDE_PATH="/usr/include/"

sanchoui-MacBook-Air:glib-2.39.2 sancho$ ./configure 

...

checking for libintl.h... yes

checking for ngettext in libc... no

checking for bindtextdomain in -lintl... no

checking if -liconv is needed to use gettext... 

checking for ngettext in -lintl... no

configure: error: 

*** You must have either have gettext support in your C library, or use the

*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html


fortunately, it found the libintl.h but there is library dependency problem.

libiconv may be required to link gettext. This problem was already mentioned in glib manual page.


2-4. Download iconv and install it.


http://www.gnu.org/software/libiconv/


sanchoui-MacBook-Air:libiconv-1.14 sancho$ ./configure --prefix=/usr

sanchoui-MacBook-Air:libiconv-1.14 sancho$ make

sanchoui-MacBook-Air:libiconv-1.14 sancho$ make install


retry configure in glib directory.

sanchoui-MacBook-Air:glib-2.39.2 sancho$ ./configure --prefix=/usr

...

checking for LIBFFI... no

configure: error: in `/Users/sancho/Downloads/glib-2.39.2':

configure: error: The pkg-config script could not be found or is too old.  Make sure it

is in your PATH or set the PKG_CONFIG environment variable to the full

path to pkg-config.


Alternatively, you may set the environment variables LIBFFI_CFLAGS

and LIBFFI_LIBS to avoid the need to call pkg-config.

See the pkg-config man page for more details.


To get pkg-config, see <http://pkg-config.freedesktop.org/>.

See `config.log' for more details


But......

libcups2 could not find a symbol in iconv, so pkg-config was not be operated!!!

Furthermore, some applications were not be launched normally also..

I guessed that the version of iconv just installed is improper with libcups2 in my macbook..


I rebooted my macbook and checked it could not be booted also. :(

Eventually I initialized again my macbook. shit.



'Code' 카테고리의 다른 글

dbus - 2  (0) 2014.01.23
dbus - 1  (0) 2014.01.15
Homebrew 설치기 - 2  (0) 2014.01.03
Homebrew 설치기 - 1  (0) 2014.01.02
bash shell script #1  (0) 2013.12.01
Posted by 스파게티코더 :