Project update‎ > ‎

2010-0110-gen-PartBasedDetector install

posted Jan 10, 2013, 2:57 AM by 陳建儒
安裝完所需3rd party library
configure 成功後,輸入make
在link時出現error:
Linking CXX executable PartsBasedDetector
CMakeFiles/PartsBasedDetector_bin.dir/demo.cpp.o: In function `__static_initialization_and_destruction_0':
/home/islab/workdir/library/boost/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/home/islab/workdir/library/boost/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/home/islab/workdir/library/boost/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
CMakeFiles/PartsBasedDetector_bin.dir/demo.cpp.o: In function `path<char*>':
/home/islab/workdir/library/boost/include/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()'
CMakeFiles/PartsBasedDetector_bin.dir/demo.cpp.o: In function `main':
/home/islab/workdir/workspace/PartsBasedDetector/src/demo.cpp:69: undefined reference to `boost::filesystem::path::extension() const'
collect2: ld returned 1 exit status
make[2]: *** [PartsBasedDetector/src/PartsBasedDetector] Error 1
make[1]: *** [PartsBasedDetector/src/CMakeFiles/PartsBasedDetector_bin.dir/all] Error 2
make: *** [all] Error 2

google後說是boost方面的問題,編譯時要再加上-lboost_system -lboost_filesystem指令
所以先拿boost的hello world程式來試一下這帖有沒有效:

#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
int main(){
       boost::asio::io_service io;
       boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
       t.wait();
       std::cout << "Hello, world!\n";
       return 0;
}
沒加上-lboost_system -lboost_filesystem指令也編不過,出現類似error
使用下列指令後,能成功編譯連結,執行後成功跑出"Hello, world!"
g++ test1.cpp -o test -L /home/islab/workdir/library/boost/lib/ -I /home/islab/workdir/library/boost/include/  -lboost_system -lboost_filesystem

接著要將指令加入Makefile中
修改~/workdir/workspace/build/PartsBasedDetector/src/CMakeFiles/PartsBasedDetector_bin.dir中的link.txt加入下列指令
-L /home/islab/workdir/library/boost/lib/ -I /home/islab/workdir/library/boost/include/  -lboost_system -lboost_filesystem

即可編譯連結成功!執行檔PartsBasedDetector存放路徑為~/workdir/workspace/build/PartsBasedDetector/src/

依照程式參數要求,指定model, input image的路徑後執行
Usage: PartsBasedDetector model_file image_file [depth_file]
可成功執行得到下列訊息,與demo.cpp裡預期結果不符:
Convolution time: 72.407629
Killed

Comments