zoukankan      html  css  js  c++  java
  • CMAKE同时编译C++和CUDA文件

    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

    解决方案

    1.  目前比较好的解决方法是在编译的时候增加 _MWAITXINTRIN_H_INCLUDED 宏。
    2.  如果是使用 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")

  • 相关阅读:
    Linux安装和配置java
    动态代理:JDK动态代理和CGLIB代理的区别
    常用算法复习
    Linux重新学习
    oracle复杂查询是sql
    oracle触发器
    oracle存储过程
    oracle数据库操作
    java知识回顾
    Spring AOP简述
  • 原文地址:https://www.cnblogs.com/phillee/p/12035182.html
Copyright © 2011-2022 走看看