build,buildmode=c 不给头文件
build, buildmode=c does not give header file
我正在尝试使用构建标志 -buildmode=c-shared
构建一个 Go 包。我希望得到两个文件 myfile.so
和 myfile.h
。但是,我只得到 .so
文件。为什么会这样,我该如何解决?
我运行的完整命令是:
go build -o myfile.so -buildmode=c-shared myfile.go
我找到了我的“说明”here,因为我正计划从 Python 调用 myfile
。
这是我的 Go 代码:
package main
import (
"C"
"bytes"
"log"
"encoding/json"
"net/http"
)
func call_request(arg1, arg2, arg3 string) {
// simple golang code to submit a http post request
}
func main () {
}
这是我的代码的基本总结,没有贴出我的全部代码。但是,请注意 运行 上面 link 中的示例创建了一个 .so
和 .h
文件。
正如@JimB 所说,问题是没有头文件:
更新代码:
package main
import (
"C"
"bytes"
"log"
"encoding/json"
"net/http"
)
//export call_request
func call_request(arg1, arg2, arg3 string) {
// simple golang code to submit a http post request
}
func main () {
}
我正在尝试使用构建标志 -buildmode=c-shared
构建一个 Go 包。我希望得到两个文件 myfile.so
和 myfile.h
。但是,我只得到 .so
文件。为什么会这样,我该如何解决?
我运行的完整命令是:
go build -o myfile.so -buildmode=c-shared myfile.go
我找到了我的“说明”here,因为我正计划从 Python 调用 myfile
。
这是我的 Go 代码:
package main
import (
"C"
"bytes"
"log"
"encoding/json"
"net/http"
)
func call_request(arg1, arg2, arg3 string) {
// simple golang code to submit a http post request
}
func main () {
}
这是我的代码的基本总结,没有贴出我的全部代码。但是,请注意 运行 上面 link 中的示例创建了一个 .so
和 .h
文件。
正如@JimB 所说,问题是没有头文件:
更新代码:
package main
import (
"C"
"bytes"
"log"
"encoding/json"
"net/http"
)
//export call_request
func call_request(arg1, arg2, arg3 string) {
// simple golang code to submit a http post request
}
func main () {
}