1. 首先是运行环境
- Ubuntu 16.04
- G++ 5.4.0
- CUDA 8.0
2. 文件结构
cv@cv:~/myproject$ tree src src/ |-- CMakeLists.txt |-- main.cc `-- base |-- CMakeLists.txt |-- mat.h |-- match_test.cc |-- match_test.h |-- match_test_cuda.cu `-- match_test_cuda.h
3. 编译过程中遇到的问题及解决方案
问题1:编译c++项目时有如下错误
问题描述
/usr/lib/gcc/x86_64-linux-gnu/5/include/mwaitxintrin.h(42): error: identifier "__builtin_ia32_mwaitx" is undefined
解决方案
- 目前比较好的解决方法是在编译的时候增加 _MWAITXINTRIN_H_INCLUDED 宏。
- 如果是使用 cmake,只需在 src/CMakeLists.txt 中增加如下语句
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_MWAITXINTRIN_H_INCLUDED")
问题2:Not support for ISO C++ 2011 standard
问题描述
error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler op
解决方案
在 src/CMakeLists.txt 中添加编译选项
set(CMAKE_NVCC_FLAGS "CMAKE_NVCC_FLAGS -std=c++11")