1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ubuntuとvimでopenframeworks開発

Last updated at Posted at 2019-05-05

vimではないですが同様のことをされていました

バージョン

ubuntu: 19.04
openframeworks: 0.10.1

ドライバとCUDA

プロプライエタリ・ドライバのインストール

ubuntu-drivers devices

でインストールされるドライバを確認

sudo ubuntu-drivers install

でインストール。nvidiaドライバもインストールされる

nvidia driverインストール後注意

nvidiaドライバをインストールした後、下記をコメント解除してから再起動しないと、起動しなくなった

/etc/gdm3/custom.conf
# WaylandEnable=false

これを

/etc/gdm3/custom.conf
WaylandEnable=false

こうする

CUDA

sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev

CUDA ZONEからrunfileをダウンロード

wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run
etc/profile.d/cuda.sh
export CUDA_HOME="/usr/local/cuda" 
export PATH="$CUDA_HOME/bin:$PATH" 
export LD_LIBRARY_PATH="/usr/local/lib:$CUDA_HOME/lib64:$LD_LIBRARY_PATH" 
export CPATH="/usr/local/include:$CUDA_HOME/include:$CPATH" 
export INCLUDE_PATH="$CUDA_HOME/include"

Vim

gVim

sudo apt update
sudo apt install vim-gtk3

Vundle

vimのプラグイン管理にVundleを使うことにした

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
.vimrc
set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
"プラグインはここに追加していく

call vundle#end()            " required
filetype plugin indent on    " required

YouCompleteMe

sudo apt install build-essential cmake python3-dev

自動補完

下記を追加

~/.vimrc
...
Plugin 'Valloric/YouCompleteMe'
...
:source %
:PluginInstall
sudo apt install build-essential cmake python3-dev
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --clangd-completer

clangd

YouCompleteMeにバンドルされているclangdは更新されていないそうなのでシステムにインストールしたバージョンを使う

sudo apt install clang-tools-8
~/.vimrc
let g:ycm_clangd_uses_ycmd_caching = 0
let g:ycm_clangd_binary_path = exepath("clangd")

Bear

clangdは completion database、すなわちcompile_commands.jsonを参照して補完してくれる。compile_commands.jsonを作成するためにBearをインストールする

sudo apt install bear

用例 bear make

vim-glsl

glslのシンタックスハイライト

~/.vimrc
...
Plugin 'tikhomirov/vim-glsl'
...
autocmd! BufNewFile,BufRead *.vs,*.fs,*.glslinc set ft=glsl
:source %
:PluginInstall

glslincファイルもシンタックスハイライトしたい

~/.vimrc
autocmd! BufNewFile,BufRead *.vs,*.fs,*.glslinc set ft=glsl

その他

clang-format

自動でフォーマットしたい

sudo apt install clang-format

用例として下記

find . -iname *.h -o -iname *.cpp | xargs clang-format -i

openframeworks

解凍したフォルダをofという名前でホームフォルダに置いた前提で下記読んでください

cd ~of/scripts/linux/ubuntu
sudo ./install_dependencies.sh
sudo ./install_codecs.sh
cd ~of/scripts/linux
./compileOF.sh -j3

例として:NoiseWorkshop

ver0.10で動くように修正してくれている(完全ではないようでした)

cd ~/of/apps
git clone https://github.com/wasawi/NoiseWorkshop.git
cd ~/of/apps/NoiseWorkshop
git checkout update_OF1.0

NoiseWorkshopで使われているアドオン

cd ~/of/addons
git clone https://github.com/kylemcdonald/ofxCv.git
git clone https://github.com/bakercp/ofxIO.git
git clone https://github.com/bakercp/ofxSerial.git
git clone https://github.com/andreasmuller/ofxAutoReloadedShader.git
git clone https://github.com/memo/ofxMSAOpenCL.git
git clone https://github.com/memo/ofxMSAPingPong.git

開発手順

空のプロジェクトをコピー

~/of/myApps/emptyExampleをコピーして好きなプロジェクト名に変える

アドオンの追記

addons.makeに使用するアドオンを改行区切りで入力

過剰だが下記のようにすればNoiseWorkshopすべての例が動く

addons.make
ofxGui
ofxOpenCv
ofxOsc
ofxCv
ofxPoco
ofxIO
ofxSerial
ofxAutoReloadedShader
ofxKinect
ofxMSAOpenCL
ofxMSAPingPong

bear make

clangdで補完できるように、vimを起動するまえにbear makeする。compile_commands.jsonができる

準備完了!

cd src
gvim ofApp.h
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?