我正在尝试学习 Cgo,所以我尝试从 Cgo 访问 aerospike 客户端
package main
// #cgo CFLAGS: -g -Wall
// #include <stdlib.h>
// #include <string.h>
// #include "aerospike-client-c/examples/put/example_utils.h"
import "C"
import (
"unsafe"
)
func main() {
retvals := C.putitnew()
_=retvals
}
但我得到以下错误。(请注意,当我 make 和 make run 时 C 程序运行成功)。
undefined reference to `example_get_opts'
./aerospike-client-c/examples/put/example.c:66: undefined reference to
`example_connect_to_aerospike'
./aerospike-client-c/examples/put/example.c:69: undefined reference to
`example_remove_test_record'
./aerospike-client-c/examples/put/example.c:78: undefined reference to
`as_record_init'
./aerospike-client-c/examples/put/example.c:79: undefined reference to
`as_record_set_int64'
/tmp/go-build283334635/b046/_x002.o: In function `as_record_set_str':
....
所以我认为问题出在 Makefile 中的配置上。我已经搜索了一整天并尝试了许多解决方案但无济于事。你能帮我如何在 Cgo 中导入 Makefile 吗?或帮助我成功执行此操作的替代方法..