go-sqlite3 icon indicating copy to clipboard operation
go-sqlite3 copied to clipboard

Error installing go-sqlite3 Go binding

Open expate98 opened this issue 14 years ago • 8 comments

I was able to get Eden Li's mysqlgo to install and working. I try to install go-sqlite3 and get the following errros

user@desktop:~/go/src/pkg/db/sqlite3$ make CGOPKGPATH=db /home/user/bin/cgo low.go gcc failed: cc1: warnings being treated as errors : In function 'wsq_config': :32: error: implicit declaration of function 'sqlite3_config' : At top level: :60: error: 'sqlite3_extended_errcode' undeclared here (not in a function) :60: error: type defaults to 'int' in declaration of '__cgo__25' :64: error: 'sqlite3_sourceid' undeclared here (not in a function) :64: error: type defaults to 'int' in declaration of '__cgo__29'

on input:

typedef struct { char *p; int n; } GoString; GoString GoString(char *p); char *CString(GoString);

include <stdlib.h>

include <sqlite3.h>

// needed since sqlite3_column_text() and sqlite3_column_name() // return const unsigned char* for some wack-a-doodle reason const char *wsq_column_text(sqlite3_stmt *statement, int column) { return (const char *) sqlite3_column_text(statement, column); } const char *wsq_column_name(sqlite3_stmt *statement, int column) { return (const char *) sqlite3_column_name(statement, column); }

// needed to work around the void()(void) callback that is the // last argument to sqlite3_bind_text(); SQLITE_TRANSIENT forces // SQLite to make a private copy of the data int wsq_bind_text(sqlite3_stmt statement, int i, const char text, int n) { return sqlite3_bind_text(statement, i, text, n, SQLITE_TRANSIENT); }

// needed to work around the ... argument of sqlite3_config(); if // we ever require an option with parameters, we'll have to add more // wrappers int wsq_config(int option) { return sqlite3_config(option); }

typeof(GoString) *__cgo__0; typeof(sqlite3_column_decltype) *__cgo__1; typeof(sqlite3_libversion) *__cgo__2; typeof(sqlite3_sql) *__cgo__3; typeof(sqlite3_reset) *__cgo__4; typeof(sqlite3_close) *__cgo__5; typeof(sqlite3_column_type) *__cgo__6; typeof(sqlite3_libversion_number) *__cgo__7; typeof(CString) *__cgo__8; typeof(sqlite3) *__cgo__9; typeof(sqlite3_extended_result_codes) *__cgo__10; typeof(wsq_config) *__cgo__11; typeof(sqlite3_busy_timeout) *__cgo__12; typeof(sqlite3_prepare_v2) *__cgo__13; typeof(sqlite3_value) *__cgo__14; typeof(wsq_bind_text) *__cgo__15; typeof(sqlite3_stmt) *__cgo__16; typeof(sqlite3_step) *__cgo__17; typeof(sqlite3_blob) *__cgo__18; typeof(wsq_column_text) *__cgo__19; typeof(sqlite3_errmsg) *__cgo__20; typeof(sqlite3_bind_parameter_count) *__cgo__21; typeof(free) *__cgo__22; typeof(sqlite3_last_insert_rowid) *__cgo__23; typeof(sqlite3_column_count) *__cgo__24; typeof(sqlite3_extended_errcode) *__cgo__25; typeof(sqlite3_changes) *__cgo__26; typeof(sqlite3_finalize) *__cgo__27; typeof(sqlite3_open_v2) *__cgo__28; typeof(sqlite3_sourceid) *__cgo__29; typeof(int) *__cgo__30; typeof(sqlite3_errcode) *__cgo__31; typeof(sqlite3_clear_bindings) *__cgo__32; typeof(wsq_column_name) *__cgo__33;

make: *** [_cgo_defun.c] Error 2 user@desktop:~/go/src/pkg/db/sqlite3$

expate98 avatar Feb 26 '10 14:02 expate98

Looks to me like you're using an SQLite version that doesn't have those functions. There's a comment in the source somewhere talking about SQLite versions and how different distros ship widely different stuff as "current" for them. What version of SQLite are you using? Could you try a newer one instead and does that make the problems go away?

phf avatar Feb 26 '10 15:02 phf

I'm running a VMWare Unbuntu 8.10 desktop appliance and installed SQLite3 with apt-get install sqlite3 libsqlite3-dev. This installed version 3.5.9. I see there is a new version 3.6.22 of SQLite. I will install this newer version and give a try.. Thanks

expate98 avatar Feb 26 '10 15:02 expate98

Just let me know what it looks like with the newer version. I hope it'll work. Otherwise I guess I have something to fix for real (I plan to ignore version stuff and just demand a minimum version, maybe I should check for that somehow in the Makefile?).

phf avatar Feb 26 '10 20:02 phf

phf, I installed the new version of SQLite 3.6.22. it appears to be giving more errors. I put the error output on http://pastebin.com/gBP6q68b (or search Bob sqlite3) Let me know if I can help. Thanks

expate98 avatar Feb 26 '10 23:02 expate98

Sorry, I have not tracked go recently, so something else may be broken. I'll give it a try now and see if I can reproduce your issue. I just checked, BTW, and I am running 3.6.20-r1 on Gentoo. So we'll see if that makes a difference.

phf avatar Feb 27 '10 05:02 phf

Hmm, I just get a bunch of warnings. I'll paste my build log here, maybe you can see something that doesn't happen for you?

phf@eggbert ~/go/src/pkg/db/sqlite3 $ make CGOPKGPATH=db /home/phf/bin/cgo low.go /home/phf/bin/6g -o go.6 core.go error.go util.go connection.go statement.go result.go classic.go set.go doc.go low.cgo1.go _cgo_gotypes.go /home/phf/bin/6c -FVw -I"/home/phf/go/src/pkg/runtime" -D_64BIT _cgo_defun.c rm -f _obj/db/sqlite3.a /home/phf/bin/gopack grc _obj/db/sqlite3.a go.6 _cgo_defun.6 phf@eggbert ~/go/src/pkg/db/sqlite3 $ make install cp _obj/db/sqlite3.a "/home/phf/go/pkg/linux_amd64/db/sqlite3.a" gcc -m64 -fPIC -O2 -o low.cgo2.o -c low.cgo2.c low.cgo2.c: In function '_cgo_sqlite3_libversion': low.cgo2.c:86: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function '_cgo_sqlite3_sourceid': low.cgo2.c:95: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function '_cgo_wsq_column_name': low.cgo2.c:107: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function '_cgo_wsq_column_text': low.cgo2.c:130: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function '_cgo_sqlite3_column_decltype': low.cgo2.c:154: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function '_cgo_sqlite3_errmsg': low.cgo2.c:247: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function '_cgo_sqlite3_sql': low.cgo2.c:279: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function '_cgo_sqlite3_prepare_v2': low.cgo2.c:340: warning: passing argument 5 of 'sqlite3_prepare_v2' from incompatible pointer type gcc -m64 -o cgo.so low.cgo2.o -lsqlite3 -shared -lpthread -lm cp cgo.so "/home/phf/go/pkg/linux_amd64/db/sqlite3.so"

phf avatar Feb 27 '10 05:02 phf

I downloaded the sqlite-amalgamation-3.6.22.tar.gz tarball and recomplied. It looks like I have a good build log now. Looks like yours now

CGOPKGPATH=db /home/user/bin/cgo low.go /home/user/bin/8g -o go.8 core.go error.go util.go connection.go statement.go result.go classic.go set.go doc.go low.cgo1.go _cgo_gotypes.go /home/user/bin/8c -FVw -I"/home/user/go/src/pkg/runtime" _cgo_defun.c rm -f _obj/db/sqlite3.a /home/user/bin/gopack grc _obj/db/sqlite3.a go.8 _cgo_defun.8 cp _obj/db/sqlite3.a "/home/user/go/pkg/linux_386/db/sqlite3.a" gcc -m32 -fPIC -O2 -o low.cgo2.o -c low.cgo2.c low.cgo2.c: In function ‘_cgo_sqlite3_column_decltype’: low.cgo2.c:61: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function ‘_cgo_sqlite3_libversion’: low.cgo2.c:70: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function ‘_cgo_sqlite3_sql’: low.cgo2.c:80: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function ‘_cgo_sqlite3_prepare_v2’: low.cgo2.c:166: warning: passing argument 5 of ‘sqlite3_prepare_v2’ from incompatible pointer type low.cgo2.c: In function ‘_cgo_wsq_column_text’: low.cgo2.c:200: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function ‘_cgo_sqlite3_errmsg’: low.cgo2.c:210: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function ‘_cgo_sqlite3_sourceid’: low.cgo2.c:301: warning: assignment discards qualifiers from pointer target type low.cgo2.c: In function ‘_cgo_wsq_column_name’: low.cgo2.c:332: warning: assignment discards qualifiers from pointer target type gcc -m32 -o cgo.so low.cgo2.o -lsqlite3 -shared -lpthread -lm cp cgo.so "/home/user/go/pkg/linux_386/db/sqlite3.so" rm low.cgo2.c user@desktop:~/go/src/pkg/db/sqlite3$

That part looks good. The Makefile does not create the test.db for me and when I compile the example.go file and run the 8.out I get this message. " /home/user/go/pkg/linux_386/db/sqlite3.so: undefined symbol: sqlite3_config"

expate98 avatar Feb 27 '10 15:02 expate98

I think I might have a simmilar issue, I'm getting http://pastie.org/private/3iyfli4s52gzx6pxnogjw

ghost avatar Jun 19 '11 06:06 ghost