C++をLinux上でコンパイル

C++ をやってみようと思って一番最初に、   あれ、Linux でどうやるんやろと思ったので、メモ

# コンパイル hello_worldを作成
$ g++ -o  hello_world hello_world.cpp

$ ./hello_world

# myIncの関数を使う場合は以下のように続きのargsで指定
$ g++ -o  hello_world hello_world.cpp myInc.cpp

C++/Linux

pip freezeの結果

pip freezeの結果

asn1crypto==0.22.0
beautifulsoup4==4.6.0
bleach==2.0.0
certifi==2017.4.17
cffi==1.10.0
chardet==3.0.4
click==6.7
cryptography==1.9
cycler==0.10.0
decorator==4.0.11
dj-database-url==0.4.2
Django==1.11.2
django-bootstrap-form==3.3
entrypoints==0.2.3
first==2.0.1
future==0.16.0
gunicorn==19.7.1
html5lib==0.999999999
idna==2.5
ipykernel==4.6.1
ipython==6.1.0
ipython-genutils==0.2.0
ipywidgets==7.0.0
jedi==0.10.2
Jinja2==2.9.6
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.1.0
jupyter-console==5.2.0
jupyter-core==4.3.0
line-bot-sdk==1.5.0
lxml==3.8.0
MarkupSafe==1.0
matplotlib==2.0.2
mecab-python3==0.7
mistune==0.7.4
nbconvert==5.2.1
nbformat==4.4.0
notebook==5.0.0
numpy==1.13.1
pandas==0.20.3
pandocfilters==1.4.2
pew==0.1.26
pexpect==4.2.1
pickleshare==0.7.4
pip-tools==1.9.0
pipenv==7.2.6
prompt-toolkit==1.0.14
psycopg2==2.7.3.1
ptyprocess==0.5.2
pycparser==2.17
Pygments==2.2.0
PyMySQL==0.7.11
pyOpenSSL==17.1.0
pyparsing==2.2.0
python-dateutil==2.6.1
pythonz-bd==1.11.4
pytz==2017.2
pyzmq==16.0.2
qtconsole==4.3.1
requests==2.18.1
resumable-urlretrieve==0.1.5
scikit-learn==0.19.0
scipy==1.0.0
seaborn==0.8.1
semver==2.7.8
simplegeneric==0.8.1
six==1.10.0
terminado==0.6
testpath==0.3.1
tornado==4.5.1
traitlets==4.3.2
typing==3.6.1
urllib3==1.21.1
virtualenv==15.1.0
virtualenv-clone==0.2.6
wcwidth==0.1.7
webencodings==0.5.1
whitenoise==3.3.0
widgetsnbextension==3.0.2
asn1crypto
beautifulsoup4
bleach
certifi
cffi
chardet
click
cryptography
cycler
decorator
dj-database-url
Django
django-bootstrap-form
entrypoints
first
future
gunicorn
html5lib
idna
ipykernel
ipython
ipython-genutils
ipywidgets
jedi
Jinja2
jsonschema
jupyter
jupyter-client
jupyter-console
jupyter-core
lxml
MarkupSafe
matplotlib
mecab-python3
mistune
nbconvert
nbformat
notebook
numpy
pandas
pandocfilters
pew
pexpect
pickleshare
pip-tools
pipenv
prompt-toolkit
psycopg2
ptyprocess
pycparser
Pygments
PyMySQL
pyOpenSSL
pyparsing
python-dateutil
pythonz-bd
pytz
pyzmq
qtconsole
requests
resumable-urlretrieve
scikit-learn
scipy
seaborn
semver
simplegeneric
six
terminado
testpath
tornado
traitlets
typing
urllib3
virtualenv
virtualenv-clone
wcwidth
webencodings
whitenoise
widgetsnbextension

topコマンドで別々のCPUの稼働状況確認する

$ top

# "1"をpush
top - 16:11:38 up 4 days, 17:22,  2 users,  load average: 1.00, 0.99, 0.78
Tasks: 177 total,   3 running, 174 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu4  : 98.7 us,  1.3 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu5  :  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu6  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu7  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 30716876 total,  3970456 free, 15388480 used, 11357940 buff/cache
KiB Swap:        0 total,        0 free,        0 used. 14824368 avail Mem

Djangoのloacle用のファイル(django.po)を作成する。

Djangoの日本語変換のための設定で以下の対応をした。

$ mkdir -p locale/ja/LC_MESSAGES
$ rsync -avz /home/vagrant/venv_oscar/lib/python3.6/site-packages/oscar/locale/ja/LC_MESSAGES/* locale/ja/LC_MESSAGES/
$ ./manage.py makemessages --locale=ja
$ ./manage.py compilemessages

## restart runserber

settings.pyはLOCALE_PATHSを設定した 。

LOCALE_PATHS = (
    os.path.join(BASE_DIR, 'locale'),
)

sarで焦った時(メモリのリソース確認)

sarコマンドを使うとmemusedが100%近くなっていた。 よくよく調べると、バッファとキャッシュの分を引く必要がある。

$ sar -r -s 16:00:00
04:44:01 PM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
04:45:01 PM    231156  30485720     99.25      2068  11327604  30375536     98.89  22381108   7170504      8832
04:46:01 PM    225416  30491460     99.27      2068  11332752  30603020     99.63  22422976   7140188      4276
04:47:01 PM    226620  30490256     99.26      2068  11329580  30602984     99.63  22458724   7101568     61324
04:48:01 PM    227464  30489412     99.26      2068  11330284  30604424     99.63  22466644   7095104      3260
Average:       272639  30444237     99.11      2068  11455693  30390549     98.94  22106370   7568499     51477

naoberry.com

$ free -h
              total        used        free      shared  buff/cache   available
Mem:            29G         17G        206M         16M         11G         10G
Swap:            0B          0B          0B

ちなみにディスクは以下の方法で確認している

$ df -h
[zeta@search ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       300G   91G  210G  31% /
devtmpfs         15G     0   15G   0% /dev
...

$ sudo du /home -h --max-depth=1 | sort -nr

Vagrantで同期できなくなってしまった...

Vagrantディレクトリの同期ができなくなってしまった。 なんかファイルシステムみたいなのを指定すれば行けた。

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "private_network", ip: "192.168.88.88"
  config.vm.hostname = "my.centos.dev"
  config.vm.synced_folder ".", "/vagrant", type: "nfs"
end

nfsrsyncはデータの同期か同じファイルシステムの差なのか・・・

stackoverflow.com