openFrameworksのインストールはこちら
Raspberry Pi 3でopenFrameworks 0.10.0を動かす - Qiita
(0.10.0から?)projectGeneratorがあるので、それをつかってプロジェクトを作る。
Linux版のprojectGeneratorではコマンドラインからプロジェクトを作ることができます。
/home/pi
にopenFrameworksのディレクトリがあるとしてやっていくので適宜読み替えてください
projectGeneratorのインストール
PGをコンパイルし、インストールします。何度か[Y/n]を聞かれるのでYをガンガンおしていく
$ cd /home/pi/openFrameworks/scripts/linux
$ ./compilePG.sh //projectGeneratorをコンパイル
Do you want to install the command line project generator? [Y/n] Y
To copy the command line project generator we need root permission.
The command line project generator was correctly installed, but the PG_OF_PATH environment variable has not been set yet.
You can create this variable by adding the following line to ~/.profile.
export PG_OF_PATH=/home/pi/openFrameworks
Do you want to add this line to ~/.profile now?? [Y/n]
To get started run: projectGenerator --help
インストールが完了したら、ヘルプを見てみましょう
$ projectGenerator --help
[ error ] No arguments
projectGenerator [options] pathName
if pathName exists, project is updated
if pathName doesn't exist, project is created
(pathName must follow options, which can come in any order)
Options:
--help Print usage and exit.
--recursive, -r update recursively (applies only to update)
--listtemplates, -l list templates available for the specified or current
platform(s)
--platforms, -p platform list (such as osx, ios, winvs)
--addons, -a addon list (such as ofxOpenCv, ofxGui, ofxXmlSettings)
--ofPath, -o path to openframeworks (relative or absolute). This
*must* be set, or you can also alternatively use an
environment variable PG_OF_PATH and if this isn't set, it
will use that value instead
--verbose, -v run verbose
--template, -t project template
--dryrun, -d dry run, don't change files
examples:
projectGenerator -o"../../../../" ../../../../apps/myApps/newExample
(create a project called newExample using a relative path for the OF root and the project. note the relative path may be different depending on where this app is located)
projectGenerator -r -o"../../../../" ../../../../examples
(recursively update the examples folder)
projectGenerator -o"../../../../" -a"ofxXmlSettings, ofxOpenCv" ../../../../apps/myApps/newExample
(create / update an example with addons)
このように表示されればOK
projectGeneratorの使い方
基本的な使い方としては、以下のようにします
$ projectGenerator -o"openFrameworksのパス" 新規プロジェクトのパス
こんなかんじで
$ projectGenerator -o"/home/pi/openFrameworks" home/pi/openFrameworks/apps/myApp/newExample
[notice ] -----------------------------------------------
[notice ] setting OF path to: /home/pi/openFrameworks
[notice ] from -o option
[notice ] target platform is: linuxarmv7l
[notice ] project path is: /home/pi/openFrameworks/home/pi/openFrameworks/apps/myApp/newExample
[notice ] setting up new project /home/pi/openFrameworks/home/pi/openFrameworks/apps/myApp/newExample
[ error ] ofFile: copyTo(): source file /home/pi/openFrameworks/scripts/templates/linuxarmv7l/qtcreator.qbs does not exist
[ error ] QtCreatorProject: error copying qbs template from /home/pi/openFrameworks/scripts/templates/linuxarmv7l/qtcreator.qbs to /home/pi/openFrameworks/home/pi/openFrameworks/apps/myApp/newExample/newExample.qbs
[notice ] saving addons.make
[notice ] project created!
[notice ] -----------------------------------------------
1 project created [notice ] in -1.52769e+09 seconds
なんかエラーがでてしまった…
qtcreator.qbs
というファイルが/home/pi/openFrameworks/scripts/templates/linuxarmv7l/
にないとのことなので/home/pi/openFrameworks/scripts/templates/linux
にあるものをコピーして持ってきます
$ cd /home/pi/openFrameworks/scripts/templates/linux
$ cp cp qtcreator.qbs ../linuxarmv7l
もう一度試してみます
~/openFrameworks/scripts/templates/linuxarmv7l $ projectGenerator -o"../../../" ../../../apps/myApps/newExample2 // 相対パスで指定しても良い
[notice ] -----------------------------------------------
[notice ] setting OF path to: /home/pi/openFrameworks/
[notice ] from -o option
[notice ] target platform is: linuxarmv7l
[notice ] project path is: /home/pi/openFrameworks/apps/myApps/newExample2
[notice ] setting up new project /home/pi/openFrameworks/apps/myApps/newExample2
[notice ] saving addons.make
[notice ] project created!
[notice ] -----------------------------------------------
1 project created [notice ] in -1.52769e+09 seconds
いけた!
$ cd ../../../apps/myApps/newExample2
$ make
$ make run
これで空のプロジェクトを実行することができました。
addonを追加する
addonを追加するには--addon
-a
オプションを使う
$ projectGenerator -o"oFのパス" -a"使いたいaddon, 使いたいaddon2, ..." 新規プロジェクトのパス
例
$ projectGenerator -o"../../../../" -a"ofxXmlSettings, ofxOpenCv" ../../../../apps/myApps/newExample