LoginSignup
4
3

More than 5 years have passed since last update.

NAOqi C++ 開発環境のインストール (macOS Sierra 版)

Last updated at Posted at 2016-11-21

はじめに

改めて環境を作り直してみました。

環境

  • MacBook (Retina, 12-inch, Early 2016)
  • macOS Sierra 10.12.1
  • Xcode Version 8.1 (インストール済み)
  • Python 2.7.10 (macOS Sierra 同梱)

コンパイラ & IDE 準備 (Compiler and IDE)

Xcode Version 8.1 をインストール済みです。

クロスプラットフォーム ビルド システムの準備 (Cross-platform build system)

まず CMake と Python 2.7 が必要になります。

CMake のインストール

CMake 公式サイト から Mac 版をダウンロードし、インストールします。今回は実施時の Latest Release (3.6.3) を使用します。

スクリーンショット 2016-11-09 3.17.00.png

CMake のパスを追加

インストール後、コマンドラインからも使えるようにパスを追加します。

$ vi .bash_profile
$ cat .bash_profile
export PATH=/Applications/CMake.app/Contents/bin/:$PATH
$ source .bash_profile

CMake の動作確認

$ cmake --version
cmake version 3.6.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Python の動作確認

macOS Sierra にデフォルトで入っている 2.7.10 をそのまま使用します。

$ python --version
Python 2.7.10

qiBuild インストール (qiBuild Installation)

pip でインストールします。

$ pip install qibuild --user
Collecting qibuild
  Using cached qibuild-3.11.6-py2-none-any.whl
Requirement already satisfied: virtualenv in /Library/Python/2.7/site-packages (from qibuild)
Installing collected packages: qibuild
Successfully installed qibuild-3.11.6
$ qibuild --version
qibuild version 3.11.6
Using Python code from /Users/Suna/Library/Python/2.7/lib/python/site-packages
Using CMake code from /Users/Suna/Library/Python/2.7/share/cmake

qibuild の設定を行います。設定ファイルが .config/qi/qibuild.xml として作成されるようです。

$ qibuild config --wizard
Found CMake: /Applications/CMake.app/Contents/bin/cmake
:: Please choose a generator
   1 Unix Makefiles     (default)
   2 Ninja
   3 Xcode
   4 CodeBlocks - Ninja
   5 CodeBlocks - Unix Makefiles
   6 CodeLite - Ninja
   7 CodeLite - Unix Makefiles
   8 Eclipse CDT4 - Ninja
   9 Eclipse CDT4 - Unix Makefiles
   10 KDevelop3
   11 KDevelop3 - Unix Makefiles
   12 Kate - Ninja
   13 Kate - Unix Makefiles
   14 Sublime Text 2 - Ninja
   15 Sublime Text 2 - Unix Makefiles
> 1
:: Please choose an IDE
   1 None   (default)
   2 QtCreator
   3 Eclipse CDT
   4 Xcode
> 1
$ cat ~/.config/qi/qibuild.xml
<qibuild version="1">
  <defaults>
    <env />
    <cmake generator="Unix Makefiles" />
  </defaults>
</qibuild>

C++ SDK インストール (SDK Installation)

こちらからダウンロードします。今回は「C++ SDK 2.4.3 Mac 64」をダウンロードしてきました。

$ cd
$ mkdir sdk
$ cd sdk
$ mv ~/Downloads/naoqi-sdk-2.4.3.28-mac64.tar .
$ tar xvf naoqi-sdk-2.4.3.28-mac64.tar
$ cd naoqi-sdk-2.4.3.28-mac64
$ qibuild init

コンパイル & サンプル実行 (Compile and run an example)

使用する toolchain の設定

$ qitoolchain create mytoolchain /Users/Suna/sdk/naoqi-sdk-2.4.3.28-mac64/toolchain.xml
Adding packages
* (1/1) libnaoqi
Done

$ qibuild add-config mytoolchain -t mytoolchain --default
$ cd core/sayhelloworld/

configure & make

$ qibuild configure
Current build worktree: /Users/Suna/sdk/naoqi-sdk-2.4.3.28-mac64
Using toolchain: mytoolchain
* (1/1) Configuring sayhelloworld
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using qibuild 3.11.6
-- Binary: sayhelloworld
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Suna/sdk/naoqi-sdk-2.4.3.28-mac64/doc/dev/cpp/examples/core/sayhelloworld/build-mytoolchain

$ qibuild make
Current build worktree: /Users/Suna/sdk/naoqi-sdk-2.4.3.28-mac64
Using toolchain: mytoolchain
* (1/1) Building sayhelloworld in Debug
Scanning dependencies of target sayhelloworld
[ 50%] Building CXX object CMakeFiles/sayhelloworld.dir/sayhelloworld.cpp.o
[100%] Linking CXX executable sdk/bin/sayhelloworld
[100%] Built target sayhelloworld

実行ファイルの確認

$ ls -l build-mytoolchain/sdk/bin/
total 792
-rwxr-xr-x  1 Suna  staff  403884 11  9 04:49 sayhelloworld

動作確認

実行するのに、環境変数 DYLD_LIBRARY_PATH を設定する必要があるのですが、El Capiptan から設定ができなくなっています。SIP を無効化すると設定ができるようになるのですが、仕組みを理解して無効化していないので、実際に試してみる場合は注意願います。

DYLD_LIBRARY_PATH の設定

$ vi ~/.bash_profile
$ cat ~/.bash_profile
export PATH=/Applications/CMake.app/Contents/bin:$PATH
export DYLD_LIBRARY_PATH=~/sdk/naoqi-sdk-2.4.3.28-mac64/doc/dev/cpp/examples/core/sayhelloworld/build-mytoolchain/sdk/lib
$ source ~/.bash_profile

実行

$ cd build-mytoolchain/sdk/bin
$ ./sayhelloworld
Wrong number of arguments!
Usage: say NAO_IP

実機には繋いでいないけど、取り急ぎ動いているようです。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3