一、cmake入門
二、c++11 feature
from:https://stackoverflow.com/questions/19774778/when-is-it-necessary-to-use-use-the-flag-stdlib-libstdc
On Linux: In general, all commonly available linux distributions will use libstdc++ by default. If you want to compile c++11 code here, use one of:
-
g++ -std=c++11 input.cxx -o a.out
-
g++ -std=gnu++11 input.cxx -o a.out
On OS X before Mavericks: libstdc++ was the default. You could use libc++
(which included c++11 library support) by passing -stdlib=libc++
.
If you want to compile c++11 code here, use one of:
-
g++ -std=c++11 -stdlib=libc++ input.cxx -o a.out
-
g++ -std=gnu++11 -stdlib=libc++ input.cxx -o a.out
-
clang++ -std=c++11 -stdlib=libc++ input.cxx -o a.out
-
clang++ -std=gnu++11 -stdlib=libc++ input.cxx -o a.out
On OS X since Mavericks: libc++ is the default. You can use libstdc++
(which does not include c++11 library support) by passing -stdlib=libstdc++
-
clang++ -std=c++11 input.cxx -o a.out
-
clang++ -std=gnu++11 input.cxx -o a.out
三、tree dir命令可以顯示文件夾文件結構
│ ├── scripts
│ │ ├── build_opencv.sh
│ │ ├── cpplint.sh
│ │ └── install_opencv.sh
│ └── src
│ ├── gradient_filter.cc
│ ├── lens_blur_filter.cc
│ ├── main.cc
│ └── quadtree.cc
└── opencv-3.3.0.tar.gz
四、運行腳本時,出現[[: not found,是因爲從Ubuntu 6.10開始,默認使用dash(theDebian Almquist Shell)而不是bash(the GNUBourne-Again Shell),需作如下處理:
ls -al /bin/sh
#如果是 Dash 可用以下方法切回 Bash(選擇 NO)
方法一
sudo dpkg-reconfigure dash
方法二
sudo ln -fs /bin/bash /bin/sh
五、“cmake_symlink_library: System Error: Read-only file system“錯誤,
六、error: ‘FilterEngine’ is not a member of ‘cv’
七、在ubuntu上編譯OS上的代碼時,可將clang/clang++改爲gcc/g++
八、opencv編譯腳本
#!/bin/sh
#
# install_opencv.sh
#
# MIT License
#
readonly CLANG_CC=$(which gcc)
readonly CLANG_CXX=$(which g++)
if [[ ! -f $CLANG_CC ]]; then
echo "gcc was not found: $CLANG_CC"
exit 1
fi
if [[ ! -f $CLANG_CXX ]]; then
echo "g++ was not found: $CLANG_CXX"
exit 1
fi
readonly SRCROOT=$(cd "$(dirname "$0")/../"; pwd)
readonly OPENCV_DIR="$SRCROOT/opencv"
readonly OPENCV_BUILD_DIR="$OPENCV_DIR/build"
echo "-- Building"
mkdir -p "$OPENCV_BUILD_DIR"
pushd "$OPENCV_BUILD_DIR"
cmake -G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE="RELEASE" \
-DCMAKE_C_COMPILER="$CLANG_CC" \
-DCMAKE_CXX_COMPILER="$CLANG_CXX" \
-DCMAKE_CXX_FLAGS="-std=c++11" \
-DCMAKE_OSX_ARCHITECTURES="x86_64" \
"$OPENCV_DIR"
make -j8
echo "-- Installing"
make install
popd
echo "-- Done"
十、編譯opencv出現錯誤“CMake Error: cmake_symlink_library: System Error: Protocol error”
I run the make command on a virtual machine. When running the command on a folder that is shared by the guest and the host OS, the system reports the above error. When running on
a folder that is accessible only on the guest OS, everything works fine.
十一、編譯安裝單個module,例如imgproc
sudo make opencv_imgproc
sudo make install