Closed raheelgup closed 10 years ago
I ran a go test and here is the result : --- FAIL: TestOpen (0.03 seconds) sqlite3_test.go:31: Failed to create table: U??S??►??3? --- FAIL: TestInsert (0.00 seconds) sqlite3_test.go:51: Failed to create table: U??S??►??3? --- FAIL: TestUpdate (0.00 seconds) sqlite3_test.go:90: Failed to create table: U??S??►?3? --- FAIL: TestDelete (0.00 seconds) sqlite3_test.go:155: Failed to create table: U??S??►??3? --- FAIL: TestBooleanRoundtrip (0.00 seconds) sqlite3_test.go:216: Failed to create table: U??S??►??3? --- FAIL: TestTimestamp (0.00 seconds) sqlite3_test.go:265: Failed to create table: U??S??►??3? --- FAIL: TestBoolean (0.00 seconds) sqlite3_test.go:347: Failed to create table: U??S??►??3? FAIL FAIL /path/to/pkg/sqlite 0.246s
Did you get succeeded in older version?
I have compile SQlite 3.7.14 which I made as a DLL from the original source from sqlite.org In go version 1.0.3 I had used your older commit : https://github.com/mattn/go-sqlite3/tree/629fe17ada2b1061f297644f7f10f9372efea8ff
That used to work. Upgrading to Go 1.1 brakes everything. I even tried the latest code from github. However I am still using the SQLite library by compiling it from the SQLites website.
While trying to build the latest go-sqlite3 (using the sqlite3_windows.c version 3.7.14.1 in this package) package as of today I get the following error :
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_threadsafe': src\db/sqlite3.go:399: undefined reference to
sqlite3threadsafe'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_step': src\db/sqlite3.go:390: undefined reference to
sqlite3step'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_reset': src\db/sqlite3.go:380: undefined reference to
sqlite3reset'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_prepare_v2': src\db/sqlite3.go:370: undefined reference to
sqlite3_preparev2'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_next_stmt': src\db/sqlite3.go:356: undefined reference to
sqlite3_nextstmt'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_finalize': src\db/sqlite3.go:345: undefined reference to
sqlite3finalize'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_exec': src\db/sqlite3.go:335: undefined reference to
sqlite3exec'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_errmsg': src\db/sqlite3.go:321: undefined reference to
sqlite3errmsg'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_column_type': src\db/sqlite3.go:311: undefined reference to
sqlite3_columntype'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_column_text': src\db/sqlite3.go:300: undefined reference to
sqlite3_columntext'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_column_name': src\db/sqlite3.go:289: undefined reference to
sqlite3_columnname'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_column_int64': src\db/sqlite3.go:278: undefined reference to
sqlite3_columnint64'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_column_double': src\db/sqlite3.go:267: undefined reference to
sqlite3_columndouble'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_column_decltype': src\db/sqlite3.go:256: undefined reference to
sqlite3_columndecltype'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_column_count': src\db/sqlite3.go:245: undefined reference to
sqlite3_columncount'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_column_bytes': src\db/sqlite3.go:235: undefined reference to
sqlite3_columnbytes'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_column_blob': src\db/sqlite3.go:224: undefined reference to
sqlite3_columnblob'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_close': src\db/sqlite3.go:213: undefined reference to
sqlite3close'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_busy_timeout': src\db/sqlite3.go:203: undefined reference to
sqlite3_busytimeout'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_bind_parameter_count': src\db/sqlite3.go:192: undefined reference to
sqlite3_bind_parametercount'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_bind_null': src\db/sqlite3.go:182: undefined reference to
sqlite3_bindnull'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_bind_int64': src\db/sqlite3.go:171: undefined reference to
sqlite3_bindint64'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_bind_int': src\db/sqlite3.go:159: undefined reference to
sqlite3_bindint'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_bind_double': src\db/sqlite3.go:147: undefined reference to
sqlite3_binddouble'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function sqlite3_open_v2': src\db/sqlite3.go:19: undefined reference to
sqlite3_openv2'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function sqlite3_last_insert _rowid': src\db/sqlite3.go:40: undefined reference to
sqlite3_last_insertrowid'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function sqlite3_changes': src\db/sqlite3.go:45: undefined reference to
sqlite3changes'
C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function `sqlite3_bind_text':
src\db/sqlite3.go:27: undefined reference to sqlite3_bind_text' C:\Users\Raheel\AppData\Local\Temp\go-build161803379\_\E_\Program_Files\mygo\server\src\db\_obj\sqlite3.cgo2.o: In function
sqlite3_bind_blob':
src\db/sqlite3.go:32: undefined reference to `sqlite3_bind_blob' collect2: ld returned 1 exit status
Sir, did you get a chance to look into this ?
What version of gcc do you use?
Version 4.4.0 : Target: mingw32 Configured with: ../gcc-4.4.0/configure --enable-languages=c,ada,c++,fortran,jav a,objc,obj-c++ --disable-sjlj-exceptions --enable-shared --enable-libgcj --enabl e-libgomp --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enab le-version-specific-runtime-libs --prefix=/mingw --with-gmp=/mingw/src/gmp/root --with-mpfr=/mingw/src/mpfr/root --build=mingw32 Thread model: win32 gcc version 4.4.0 (GCC)
At least with looking your build log, The things I can guess a cause, you go doesn't work for cgo.
So is this a Go bug ?
Could you please try to run follow?
package main
/*
#include <stdio.h>
*/
import "C"
func main() {
C.puts(C.CString("hello world"))
}
$ go run helloworld.go
It ran and there was no output and no error as welll.
I upgraded to gcc 4.7.0 and your helloworld code is now working. However I still get the build errors even though sqlite3.dll is there in the lib folder : C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_threadsafe': src\db/sqlite3.go:399: undefined reference tosqlite3threadsafe' C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf unc_sqlite3_step': src\db/sqlite3.go:390: undefined reference tosqlite3step' C:\Users\Raheel\AppData\Local\Temp\go-build161803379\E_\Program_Files\mygo\server\src\db_obj\sqlite3.cgo2.o: In function cgo_85d05e2f97ba_Cf ...............
How can I debug this ?
Try to add directory of sqlite3.dll into $PATH environment?
I have already added that to the E:\mingw\lib and E:\mingw\bin Is it that the compiler cannot find the sqlite3.dll and hence the errors ?
Is it that the compiler cannot find the sqlite3.dll and hence the errors ?
Yes, I doubt that. BTW do you have sqlite3.h in E:/mingw/include ?
Yes. I do have the sqlite3.h and the sqlite3ext.h in the include folder as well. Any way to further debug this ?
I have SQLite3 3.15.x on Windows 7 64 bit but the GCC and go (version 1.1) are 32 bit.
Ah, are you trying to build 32bit module on 64bit OSs!?
Yes. I used the MSVC++ 2010 Express edition to build the sqlite3.dll I had done so previously as well during go 1.0.3 and it worked.
I have same trouble.
go-sqlite3 can work on go1.0,
after i upgraded to go1.1 in today, it doesnt work again. any query is output U??S??►??3?
os:window xp gcc:4.4.0.
need your help,mattn
Since I now got GCC working I tried to compile the commit : https://github.com/mattn/go-sqlite3/tree/629fe17ada2b1061f297644f7f10f9372efea8ff Though this will compile, it doesnt work. Using the new sqlite3.go and other files, I get the compile errors. Why would the earlier commit be able to compile without issues while the new commit fail ?
I am sorry for the multiple posts but I also noticed one more strange behaviour. In GCC 4.7.0 from MinGW website the errors have the function names as _sqlite_bind_text and so on whereas the GCC version 4.7.1 from TDM is having the errors with function names as sqlite_bind_text (without the underscore) I dont know if this will be helpful.
I got this working by removing the following line from the file sqlite3_other.go : // +build !windows
I guess this instructs the compiler to ignore it for windows and the CGO pkg_config line is here. Hence it never found the include files. Removed that and everything is working. Please confirm if this is right.
sqlite3_other.go is the code for non-windows.
Sir, but the pkg-config (#cgo pkg-config: sqlite3) line is in this file sqlite3_other.go This line is a CGO directive and is not there in any other file. Isnt this required on Windows ? Otherwise how would the compiler find the sqlite3 dll in MinGW ?
On windows, go-sqlite3 is built with amalgamation code sqlite3_windows.c
. So it don't require pkg-config.
https://github.com/mattn/go-sqlite3/blob/master/sqlite3_windows.go
Sir, but there is no include lines in that. Dont we have to build the DLL first with MSVC ? I built the latest sqlite 3.7.17 with MSVC and added it to the mingw lib folder. Then I commented the line (// +build !windows) and it worked.
Dont we have to build the DLL first with MSVC ?
Yes, on windows go-sqlite3 become static-linked.
Yes, it does become static linked but the DLL is needed in the LIB folder so that it can statically link it right ? Otherwise go doesnt compile the binary if the DLL is not found. Here are my steps to run sqlite3 with go-sqlite3 : 1) Make the sqlite3.dll from the latest amalgamation with MSVC and place it in the MinGW "lib" folder 2) Place the sqlite3.h and sqlite3ext.h in the MinGW include folder. 3) Add the sqlite3.pc file in the MinGW "lib" folder 4) Removed the (// +build !windows) from sqlite3_other.go
It now works. What steps are wrong here ?
Yes, it does become static linked but the DLL is needed in the LIB folder so that it can statically link it right ?
No, no require to build on windows.
On windows, it need just only sqlite3.h
I close this. Please reopen if still have problem.
I have SQLite3 3.15.x on Windows 7 64 bit but the GCC and go (version 1.1) are 32 bit. The SELECT queries are not working for some reason. At times its leads to PANIC when the query is executed. Is there an issue with 32 bit version on Windows ? The following is the error returned with err.Error() : U??S??►??3?