dongzhe3171 2017-06-30 23:53
浏览 378

我可以更改cgo使用的默认编译器吗?

I am trying to execute cgo code under ubuntu 14.04, it seems like cgo assume CC/CXX to be gcc/g++. And I need to explicitly specify CC/CXX in order to use, say, clang. Can I configure default compiler used through go's build constraints?

Thanks!

  • 写回答

1条回答 默认 最新

  • dongpang1898 2019-03-01 20:58
    关注

    If you're using the go command to build the code, then the CC_FOR_TARGET environment variable determines where go looks for the C compiler.

    e.g. env CGO_ENABLED=1 CC_FOR_TARGET=/path/to/compiler go build foo.go

    It doesn't look like it's possible to specify the compiler using build constraints, though it is somewhat possible to specify CFLAGS. See the docs below for details.

    Reference: https://golang.org/cmd/cgo/#hdr-Using_cgo_with_the_go_command

    评论

报告相同问题?

悬赏问题

  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案