dongmang3961 2018-06-25 18:46
浏览 390

cgo不包含CXXFLAGS

I want to call C code in Golang:

// #cgo CFLAGS: -I/usr/include/c++/8.1.1/bits
// #cgo CXXFLAGS: -std=gnu++11
// #include "c++0x_warning.h"
import "C"

but get error:

In file included from ./main.go:5:
/usr/include/c++/8.1.1/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

So cgo doesn't use CXXFLAGS. I tried -std=c++11 and it doesn't work too. What I do wrong?

$ go version
go version go1.10.3 linux/amd64
  • 写回答

1条回答 默认 最新

  • douguangxiang0363 2018-06-29 21:51
    关注

    Please refer to the following SO question: Difference between CPPFLAGS and CXXFLAGS in GNU Make to figure out which flags you really need in the context of your program.

    If you are calling pure C code (and not C++ code), I don't think you will need CXX_FLAGS:

    CPPFLAGS are supposed to be flags for the C PreProcessor; CXXFLAGS are flags for the C++ compiler.

    You might also want to check your go env. If you really need this flag, you can try to compile your program using env CGO_CXXFLAGS="-std=c++11" go build <YOUR_CODE>.

    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法