2016年6月7日 星期二

Eclipse C++ 打包

在程式的主資料夾建立folder : build
裡面放一個執行檔 build.sh

***
WORKDIR=$(cd "$(dirname "$0")"; pwd)
cd $WORKDIR/../

#將系統內建的也打包進去
find . -type f -perm /a+x -exec ldd {} \; | grep so | sed -e '/^[^\t]/ d' | sed -e 's/\t//' | sed -e 's/.*=..//' | sed -e 's/ (0.*)//' | sort | sed '/^\s*$/d' |  uniq | sed -e '/x86_64-linux-gnu/d' | sed -e '/lib64/d' | sed 's/^/sudo cp /' | sed 's?$? '`pwd`/lib'?' >> copy.sh

#find . -type f -perm /a+x -exec ldd {} \; | grep so | sed -e '/^[^\t]/ d' | sed -e 's/\t//' | sed -e 's/.*=..//' | sed -e 's/ (0.*)//' | sort | sed '/^\s*$/d' |  uniq | sed 's/^/sudo cp /' | sed 's?$? '`pwd`/lib'?' >> copy.sh

mkdir lib
chmod +x copy.sh
./copy.sh
rm copy.sh

***
註解的不將系統內建的連結檔放入lib

2016年5月9日 星期一

NO_PUBKEY 575159689BEFB442

Ubuntu 14.04 更新的時候出現了

"Error GPG: http://download.fpcomplete.com stable Release: NO_PUBKEY 575159689BEFB442"

解決方式:
wget -q -O- https://s3.amazonaws.com/download.fpcomplete.com/ubuntu/fpco.key | sudo apt-key add -



2016年5月4日 星期三

Sed 小應用:刪除行尾(首)的最後一個字元


刪除每一行的最後一個字元
sed 's/.$//'

".$" 代表著行尾的前一個任意字元

利用sed來替換文字
sed's/想要被替換的字/替換的字/'

行首

sed 's/^/string/' 行首用'string'代替



2016年5月3日 星期二

google protobuff 3.0.0, ImportError: cannot import name symbol_database

安裝好caffe之後 進行演算法偵測
出現了 "ImportError: cannot import name symbol_database"

解決的方法是移除default的 python-protobuf

$: sudo apt-get remove python-protobuf


**
protobuf-3.0.0 有一個bug

按照以下網址修改
作者:xfxyjwf
https://github.com/xfxyjwf/protobuf/blob/494716a682ef854168e92231a3cdcc89d587d9b9/src/google/protobuf/arena.h

重新編譯google-protobuf即可

無法取得以下的密鑰ID 的公鑰: 1397BC53640DB551

這是google chrome的問題


wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -


That will fix it

Source:
https://www.reddit.com/r/linux4noobs...no_public_key/


2016年3月24日 星期四

Multiple “could not be resolved” problems using Eclipse

最近用eclipse的時候遇到一個很奇怪的問題
我在使用C++11的新功能 chrono的時候 會發現我已經更改了
Properties > C/C++ Build > Setting > GCC C++ Complier
> Dialet  > Language standard = ISO C++1y (-std=c++1y)

但在build project的時候, 會出現很多很多error, 雖然最後仍然可以成功的build出程式
可是無法使用eclipse 來執行程式, 只能用terminate 來啟動

後來上網查到解決辦法

***
Go to Project -> Properties -> C/C++ General -> Preprocessor Include Paths, Macros, etc. -> Providers -> CDT GCC built-in compiler settings, deactivate Use global provider shared between projects and add the command line argument -std=c++11.

The eclipse live code analysis does not share the same settings with the build compiler. You can also change the setting globally (not just for the project) in Window -> Preferences -> C/C++ -> Build -> Settings -> CDT GCC Built-in Compiler Settings.

**
更改完這些設定之後Rebuild project 
錯誤訊息就會消失了!

2016年3月15日 星期二

python-check there is a existing file in a folder

import os
bIsExist = os.path.exists(file_path)

if there is a file with same path, then bIsExist is True.