how to specify header file and library path when building a go program which import a cgo package?

huangapple go评论88阅读模式
英文:

how to specify header file and library path when building a go program which import a cgo package?

问题

我有一个名为A的简单Go程序,它需要将一个名为B的cgo项目作为模块导入。
B需要包含一个头文件并链接一个共享对象。这个头文件和共享对象不在标准路径(/usr/include,/usr/lib),而是在手动编译的工作目录中。

我该如何在A的源代码目录中运行go build,同时为B指定头文件和共享对象文件的路径?
我需要使用CMake来完成。

如果有人能帮忙,我将不胜感激。

谢谢。

英文:

I have a simple go program named A and it needs to import a cgo project named B as a module.
B needs to include a header file and link a shared object. The header file and shared object are not standard paths (/usr/include, /usr/lib) but in a work directory compiled manually.

How I can run go build in A's source directory but specify header/so file path for B?
I need to use CMake to do it.

Appreciated it if someone can help.

Thanks,

答案1

得分: -1

已经使用ExternalProject自定义构建命令解决了这个问题。

英文:

already use ExternalProject custom build command to work around it.

huangapple
  • 本文由 发表于 2021年9月28日 15:44:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/69357654.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定