Prerequisities
Xcode
- Install Xcode from the Mac App Store.
- OpenCPN official builds support OS X 10.7 and newer. In order to build in this way, the old 10.7 SDK is needed. Old SDKs are unfortunately not available as separate download, so they have to be extracted from older Xcode versions. One way to do this is to use the script available at https://github.com/devernay/xcodelegacy.
Build Tools
- Install Homebrew, following the instructions on http://brew.sh.
- 위 사이트에 들어가 보면 install Homebrew라고 있는데 아래와 같이 터미널에서 치면 된다
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install cmake and gettext:(그대로 입력한다)
$ brew install cmake $ brew install gettext
- Create symbolic links to the gettext binaries so they can later be found by cmake:(그대로 입력한다)
$ sudo ln -s /usr/local/Cellar/gettext/0.19.4/bin/msgmerge /usr/local/bin/msgmerge $ sudo ln -s /usr/local/Cellar/gettext/0.19.4/bin/msgfmt /usr/local/bin/msgfmt
wxWidgets
Note that the wxWidgets package available via homebrew is not compatible with OpenCPN. Thus we need to build and install wxWidgets manually.
- Download the source package from https://sourceforge.net/projects/wxwindows/files/3.0.2/wxWidgets-3.0.2.t....
- Unpack the source:
$ tar xjf wxWidgets-3.0.2.tar.bz2(다운로드 후 압축을 푼다)
- Configure the build:
$ cd wxWidgets-3.0.2 $ mkdir build-release && cd build-release $ ../configure --enable-unicode --with-osx-cocoa --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ --with-macosx-version-min=10.7 --enable-aui --disable-debug --enable-opengl --without-liblzma
여기서 문제가 발생했다. MacOSX10.7.sdk가 아니라 MacOSX10.10.sdk로 고쳐서 입력해야 제대로 작동한다
- Build and install (note, this may take a long time):
$ make $ sudo make install
Building OpenCPN
There are two ways to build OpenCPN - using the Terminal, or using Xcode.
Using the terminal is the official way, however it is also possible to use cmake (from the terminal) to create an Xcode project which we can then use to work with OpenCPN.
Regardless of which method we use, the first steps are the same:
- Get the OpenCPN source:
$ git clone https://github.com/OpenCPN/OpenCPN.git
- Create the build directory, where our local builds will take place, so that we don't work directly in the source tree:
$ mkdir OpenCPN/build && cd OpenCPN/build
Build Method 1 - Using the Terminal (오류가 나면서 컴파일이 안된다)
- Prepare our build environment:
$ export MACOSX_DEPLOYMENT_TARGET=10.7 $ cmake ..
- Build OpenCPN:
$ make
Build Method 2 - Using Xcode(OpenCPN/build 폴더가 아니라 그냥 OpenCPN 폴더에서 실행한다)
- Create the Xcode project:
$ export MACOSX_DEPLOYMENT_TARGET=10.7 $ cmake -G Xcode ../
- Open the `OpenCPN.xcodeproj` file in Xcode, and use the "Build", "Run", "Debug", etc features as normal.
To use the "Run" action you need to build the "OpenCPN" target, rather than the default "ALL_BUILD" target.
여기까지 하면 OpenCPN 프로젝트 파일을 열어서 Xcode에서 컴파일 할 수 있게 된다.
그러나 오류가 나면서 실행이 되지 않는다. 주요 원인은 #include "linux/serial.h" 파일을 찾을 수 없다는 것이다.
#include 라인을 일단 주석처리한 후 아래의 내용으로 대체해서 컴파일 한다.
#define TIOCGSERIAL 0x541E #define TIOCSSERIAL 0x541F #define ASYNC_SPD_CUST 0x0030 /* Use user-specified divisor */ #define ASYNC_LOW_LATENCY 0x2000 /* Request low latency behaviour */ struct serial_struct { int type; int line; unsigned int port; int irq; int flags; int xmit_fifo_size; int custom_divisor; int baud_base; unsigned short close_delay; char io_type; char reserved_char[1]; int hub6; unsigned short closing_wait; /* time to wait before closing */ unsigned short closing_wait2; /* no longer used... */ unsigned char *iomem_base; unsigned short iomem_reg_shift; unsigned int port_high; int reserved[1]; };