2015년 11월 9일 월요일

Installing NASM,Eclipse and QEMU on Macbook Pro 2015 early

My development Environment
Macbook Pro 2015 early
OS X 10.11.1 El Capitan


I am studying to make Operating System. So I am downloading and installing programs.

It is a part of process. 

At first, Download and install Homebrew.  (It is easy tool to download and install programs)


$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

-How to install NASM
$brew install nasm
-How to install Eclipse
click download button on http://www.eclipse.org/ and
Eclipse IDE for C/C++ Developers 
-How to install Java Runtime Environment(JRE)
enter http://www.oracle.com/technetwork/java/index.html 
then, click downloads, Java Runtime Environment
-How to install QEMU
$brew install qemu 
how to launch
$qemu-system-x86_64

2015년 11월 8일 일요일

Make Cross-Compiler(2); How to Build and Install GCC on Macbook Pro 2015 early

- My Development Environment
Mac OS X 10.11.1 El Capitan
already installed Binutils
already installed Xcode

It is similar to build and install Binutils but your time can waste too much.
Please do this when you have enough time.

- Procedure

1. Download  GCC Source codes at https://gcc.gnu.org/ (click 'our mirror sites' after clicking any versions)

2. extract your files
 example)  $ cd ~/Downloads/
                 $ tar -zxvf gcc-5.2.tar.gz  (tar.gz files can extract as zxvf command.)
                 $ cd gcc-5.2   (move to ~/Downloads/gcc-5.2/)
3. downloads libraries when your computer need as this command.
 $ ./contrib/download_prerequisites

4. setup your platform and location.
$ export TARGET=x86_64-pc-linux
$ export PREFIX=/opt/cross  (<- this location is same to setup binutils)

 Confirm .bash_profile  (It is already have after doing Make Cross-Compiler(1))
 You can see
export PATH=/opt/cross/bin:$PATH
when you type  $cat ~/.bash_profile

5. build and install

$ ./configure --target=$TARGET --prefix=$PREFIX --enable-64-bit-bfd --disable-shared --disable-nls
$ make configure-host
$ make LDFLAGS="-all-static"
$ sudo make install

6. How to test gcc cross-compiler after install that.
$ /opt/cross/bin/x86_64-pc-linux-gcc -dumpspecs | grep -A1 multilib_options

result

I use too much time. cheer up! . It is really hard to me. So I leave this text.


-My Problems
C compiler cannot create executables when I type $./configure ~~~blar~~~
Solve this problem to delete installed binutils then to reinstall them in my case.
$rm -rf /opt  can removes all the binutils.  ***Use caution when you type rm command.


References
Book <64비트 멀티코어 OS 원리와 구조>

Procedure of Explanation.
http://nayuta.net/64%EB%B9%84%ED%8A%B8_%EB%A9%80%ED%8B%B0%EC%BD%94%EC%96%B4_OS_%EC%9B%90%EB%A6%AC%EC%99%80_%EA%B5%AC%EC%A1%B0/OS_X%EC%97%90%EC%84%9C_%EA%B0%9C%EB%B0%9C%ED%99%98%EA%B2%BD_%EA%B5%AC%EC%B6%95%ED%95%98%EA%B8%B0

2015년 11월 7일 토요일

Make Cross-Compiler(1); How to Build and Install GNU Binutils on Macbook pro 2015 early


-My Development Environment
 Mac OS X 10.11.1 El Capitan  on Macbook pro 2015 early
 already installed Xcode

* '$' means Teminal Command

- Procedure
Before typing on Command Line.
 Download Binutils 2.25.1.tar.gz  from http://www.gnu.org/software/binutils/
and type these
$ tar -zxvf Binutils 2.25.1.tar.gz
$ cd binutils-2.25.1


 1. Type These Commands
    $ export TARGET=x86_64-pc-linux
    $ export PREFIX=/opt/cross      <- This location(/opt/cross) can be any folders which you want.

2. Type  $ cd ~/
             $ ls -a
 and  find .bash_profile or .profile  If you don't have make .bash_profile to use Vim
($ vim .bash_profile)

3. Type   export PATH=/opt/cross/bin:$PATH

4. Save and quit
     ESC button and :wq

5. Type

  $ ./configure --target=$TARGET --prefix=$PREFIX --enable-64-bit-bfd --disable-shared --disable-nls

  $ make configure-host
  $ make LDFLAGS="-all-static"

then when your computer is no problem,  type $ sudo make install   then input password


-References

Book <64비트 멀티코어 OS 원리와 구조 -한빛미디어>
Sites
http://nayuta.net/64%EB%B9%84%ED%8A%B8_%EB%A9%80%ED%8B%B0%EC%BD%94%EC%96%B4_OS_%EC%9B%90%EB%A6%AC%EC%99%80_%EA%B5%AC%EC%A1%B0/OS_X%EC%97%90%EC%84%9C_%EA%B0%9C%EB%B0%9C%ED%99%98%EA%B2%BD_%EA%B5%AC%EC%B6%95%ED%95%98%EA%B8%B0


How to setup GCC (GNU Complier Collections) on Mac OS X and test to use Vim.

If you contact GCC firstly as this page, please don't believe everything. quest yourself about this page.

 My development environment
: Mac OS X 10.11.1 El Capitan on Macbook pro 2015 early
  Xcode 6.3.1

* I am studying the book; 64비트 멀티코어 OS 원리와 구조.  GCC installation is first procedure for it.
  It is similar to '2.1 GCC 설치' page 50 to  '2.2 크로스 컴파일러 만들기' page 69. but It is for Windows. So I need to do on Mac OS X.

1. Open Terminal
 (Ctrl+ Space)  terminal.app

2. type   $xcode-select --install     (* "$" means on terminal)
    *If you don't know you have GCC or not, type this sentence $ gcc --version

3. click Install(설치)

4. type, too. $gcc -v

completed installation GCC.


until now, how to test GCC on Vim
Vim (old version Vi) is already installed on Mac OS X.
open your terminal.

$vi File_Name       example) $vi test.c

1. Can input codes after pushing a or i or u button.

#include <stdio.h>

int main( int argc, char** argv)
{
     printf("Hello World\n");
     return 0;
}

2. push ESC.

3. when your cursor located bottom, type :w       (it means save)

[Common Test]

4. $gcc -o test.out   (It makes test.out file and It is for test)

5. $ ./test.out   

You can see  Hello world


[My case Test]
4. $gcc -m32 -o test32 test.c
    $gcc -m64 -o test64 test.c 

5. $./test32
    $./test64

If you see  Hello World,  Your GCC can apply 64bit and 32bit.






'ls' command to see files on this location.


-Reference
Book <64비트 멀티코어 OS 원리와 구조 1>

How to use Vim (in Korean)
http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/Vim  

Setup Development Environment for 64비트 멀티코어 OS 원리와 구조
http://nayuta.net/64%EB%B9%84%ED%8A%B8_%EB%A9%80%ED%8B%B0%EC%BD%94%EC%96%B4_OS_%EC%9B%90%EB%A6%AC%EC%99%80_%EA%B5%AC%EC%A1%B0/OS_X%EC%97%90%EC%84%9C_%EA%B0%9C%EB%B0%9C%ED%99%98%EA%B2%BD_%EA%B5%AC%EC%B6%95%ED%95%98%EA%B8%B0