【发布时间】:2014-06-12 10:56:11
【问题描述】:
我正在尝试通过 C 将 sqlite3 与 cgo 一起使用(我知道 go 有一个 sqlite3 包装器,但想尝试这种方式)。这个程序给了我一个错误信息
(Undefined symbols for architecture x86_64:
"_sqlite3_open", referenced from:
__cgo_1d4838eae1de_Cfunc_sqlite3_open in cGo.cgo2.o
(maybe you meant: __cgo_1d4838eae1de_Cfunc_sqlite3_open)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
,我不明白为什么 - 有人可以帮助我了解如何打开新的数据库流吗?
// cGo
package main
/*
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
*/
import "C"
//import "fmt"
func main() {
var t* C.sqlite3
C.sqlite3_open("test.db", t)
}
【问题讨论】: