Giter Site home page Giter Site logo

Comments (85)

MstrVLT avatar MstrVLT commented on July 16, 2024 2

https://medium.com/@yaravind/go-sqlite-on-windows-f91ef2dacfe

from go-sqlite3.

matrixik avatar matrixik commented on July 16, 2024

Check here: https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/VNP6Mwz_B6o

I fixed __divdi3: not defined errors with adding -lgcc_s to LDFLAGS in C:\Go\src\pkg\github.com\mattn\go-sqlite3\sqlite3_windows.go file:

package sqlite

/*
#cgo CFLAGS: -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe
#cgo LDFLAGS: -lmingwex -lmingw32  -lgcc_s
*/
import "C"

and then go install in that folder.

Best regards

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Hmm, libgcc_s.a is provided for mingw64. it don't exists in my mingw/lib directory.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

I can confirm that works for me on a 32-bit and 64-bit Windows now.

I have libgcc_s.a in "C:\MinGW\lib64" (mingw64) on the 64-bit system. On the 32-bit system I have "C:\MinGW\lib\gcc\mingw32\4.6.2\libgcc_s.a" in case that helps at all.

Thanks & Regards

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Oh, ok, I'll check it soon.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Hmm, if linking libgcc_s.a on mingw32 32bit, example/main crash.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@stever If change as following, can it succeeded to build?

#cgo windows/386 CFLAGS: -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe
#cgo windows/386 LDFLAGS: -lmingwex -lmingw32
#cgo windows/amd64 CFLAGS: -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe
#cgo windows/amd64 LDFLAGS: -lmingwex -lmingw32  -lgcc_s

from go-sqlite3.

stever avatar stever commented on July 16, 2024

Build succeeded but then when I run the example it fails with similar error messages, on win32.

I think I need the -lgcc_s flag on win32 and not win64.

The example/main didn't crash for me when I ran it with this on either architecture. I made sure sqlite3.dll and include files were not on the path either in case that was having an effect. I have a fairly clean setup so far as I know and the suggestion from matrixik works for me.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

I'm checking this issue on windows 32bit and It don't require libgcc_s.a for building.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

Sure, seem to need to link to it on win32 though. I didn't need to link to it with win64.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Hmm, inversed result?

from go-sqlite3.

stever avatar stever commented on July 16, 2024

I don't know why linking libgcc_s.a on win32 crashes for you. Maybe we have different mingw32 versions? I've used a fairly recent mingw-get-inst installer.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

What version of go?

from go-sqlite3.

stever avatar stever commented on July 16, 2024

1.0.3

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Me too...

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Ah, but I'm using hg tip.

from go-sqlite3.

srinathh avatar srinathh commented on July 16, 2024

Hi, just forked go-sqlite3 & added the following flags in sqlite3.go & was able to subsequently do a simple "go get" to install the package. Example compiles perfectly on win32 with standard MinGW. Had the same issues & soln. building Russ Cox's sqlite3 bindings... libgcc_s.a contains the "__divdi3" which gets rid of not found etc errors. Removing the stack protection gets rid of "__chkstk_ms" not found errors which i simply wasn't able to figure out (this is supposed to be defined in the standard libgcc.a which is included by default by MinGW but somehow wasn't getting linked)

#cgo LDFLAGS: -lgcc_s
#cgo CFLAGS: -fno-stack-check -fno-stack-protector -mno-stack-arg-probe

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

That flags is already put in sqlite3_windows.go

from go-sqlite3.

srinathh avatar srinathh commented on July 16, 2024

hmmmm..... a simple "go get" was throwing a whole bunch of starting with __divdi3 type of errors on compiling the test program before i made this change. Wonder why.... maybe because of -lgcc_s?

from go-sqlite3.

matrixik avatar matrixik commented on July 16, 2024

@mattn no it's not, you didn't push it to github

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@matrixik ? I didn't change anything. What you want?

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@srinathdevelopment

maybe because of -lgcc_s?

I guess it so.

from go-sqlite3.

matrixik avatar matrixik commented on July 16, 2024

You didn't add -lgcc_s to sqlite3_windows.go
https://github.com/mattn/go-sqlite3/blob/master/sqlite3_windows.go
that's why @srinathdevelopment still see errors with go get (and I too)

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@matrixik see above. if add -lgcc_s on win32, it occur crashed.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

@mattn That's true for you, but is it true for others? Not true for me. It's only required in my win32 build but doesn't hurt to have it for both that and 64-bit windows too.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@stever if it occur on your environment just only, I'll change to

#cgo windows/386 CFLAGS: -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe
#cgo windows/386 LDFLAGS: -lmingwex -lmingw32
#cgo windows/amd64 CFLAGS: -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe
#cgo windows/amd64 LDFLAGS: -lmingwex -lmingw32  -lgcc_s

Is this ok?

from go-sqlite3.

stever avatar stever commented on July 16, 2024

@mattn Really is it needed in 64-bit windows at all? Weird that I have the complete opposite. I'll just fork it to work around the issue I have, but I'm not assuming right now I'm the only person that does. I've tested this on a bunch of computers with consistent results.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@stever Where did you get sqlite3.dll or header files ?

from go-sqlite3.

stever avatar stever commented on July 16, 2024

@mattn I've tested with an without my own sqlite3.dll and header files. I made a fork before just to remove the static include for windows here as a special case. However, on windows I still like this so right now I'm not using anything outside of your repository plus the '-lgcc_s' fix mentioned above.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

I'm confusing...

from go-sqlite3.

stever avatar stever commented on July 16, 2024

Maybe I've confused you... I didn't/don't fully understand the problem but the suggested fix '-lgcc_s' worked for me and that's all I needed. It's neat to be able to include SQLite statically on windows so I prefer this than the DLL option that I had mentioned as my initial workaround. It would be ideal if the '-lgcc_s' fix work for you and everyone else.

It would be useful if other people will confirm there experience with this on 32-bit windows.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Is there anyone who occur this issue without stever?

from go-sqlite3.

matrixik avatar matrixik commented on July 16, 2024

Yes, me.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@stever @matrixik What OS do you use to build/run ? I'm building this on WindowsXP 32bit.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

@mattn I'm mostly using 32-bit Windows 7 and 64-bit Windows 8.

from go-sqlite3.

srinathh avatar srinathh commented on July 16, 2024

in case this helps... i built using -lgcc_s on Win7 32 bit, MinGW & Go
latest versions as of last weekend
On Dec 7, 2012 6:42 PM, "mattn" [email protected] wrote:

@stever https://github.com/stever @matrixikhttps://github.com/matrixikWhat OS do you use to build/run ? I'm building this on WindowsXP.


Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-11129535.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Are there someone using Windows XP 32bit ? hmmmmmm

from go-sqlite3.

matrixik avatar matrixik commented on July 16, 2024

Windows 7 x32

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@stever what are you saying does not work on win32, crash? broken results?

from go-sqlite3.

stever avatar stever commented on July 16, 2024

@mattn Exactly as in the comment from @matrixik above - #27 (comment)

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@stever How about to add -lgcc instead of -lgcc_s ? I got succeeded to build and run example/main. If you don't get fail, I'll update.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

@mattn I tried and sadly that's the same as before.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@stever once more, please try to add -static-libgcc.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

@mattn Same result.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Hmm, It read some documentation, but it seems that libgcc_s.a is not provided for 32 bit OSs.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

I'm using MinGW (mingw.org) on 32-bit Windows and MinGW-w64 (mingw-w64.sourceforge.net) on 64-bit Windows.

Maybe that's why -lgcc_s isn't required to run your example/main.go on 64-bit Windows.

Do you use the same?

I've got Windows XP here - not tried it yet, but I could try and replicate your problem here if that helps.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@stever

Please try to get whether divdi3 is contained in libgcc.a ?

C:\MinGW\lib\gcc\mingw32\4.7.2>nm -o libgcc.a | grep divdi3
libgcc.a:_divdi3.o:00000000 b .bss
libgcc.a:_divdi3.o:00000000 d .data
libgcc.a:_divdi3.o:00000000 r .eh_frame
libgcc.a:_divdi3.o:00000000 t .text
libgcc.a:_divdi3.o:00000000 T ___divdi3
libgcc.a:_udivdi3.o:00000000 b .bss
libgcc.a:_udivdi3.o:00000000 d .data
libgcc.a:_udivdi3.o:00000000 r .eh_frame
libgcc.a:_udivdi3.o:00000000 t .text
libgcc.a:_udivdi3.o:00000000 T ___udivdi3
libgcc.a:bid64_div.o:         U ___udivdi3
libgcc.a:bid128_div.o:         U ___udivdi3

divdi3 is contained on my environment.

libgcc.a:_divdi3.o:00000000 T ___divdi3

Or, libgcc_s.a contains it ?

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

It seems that divdi3 is exported as shared function in libgcc_s.a

C:\MinGW\lib\gcc\mingw32\4.7.2>nm -o libgcc_s.a | grep divdi3
libgcc_s.a:d000118.o:00000000 T ___udivdi3
libgcc_s.a:d000118.o:00000000 I __imp____udivdi3
libgcc_s.a:d000040.o:00000000 T ___divdi3
libgcc_s.a:d000040.o:00000000 I __imp____divdi3

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

So, I can't understand why you can't build with libgcc.a.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

I get that line also:

libgcc.a:_divdi3.o:00000000 T ___divdi3

However the path I have is C:\MinGW\lib\gcc\mingw32\4.6.2

from go-sqlite3.

srinathh avatar srinathh commented on July 16, 2024

the error comes because for some reason in 32 bit MinGW, these functions
are defined in libgcc_s.a rather libgcc.a... so these errors come. As i
said, this error is not unique to this library's config, happens if you try
to build sqlite3 with other go libraries as well
On Dec 10, 2012 4:46 PM, "Steven Robertson" [email protected]
wrote:

I get that line also:

libgcc.a:_divdi3.o:00000000 T ___divdi3

However the path I have is C:\MinGW\lib\gcc\mingw32\4.6.2


Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-11189377.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

However the path I have is C:\MinGW\lib\gcc\mingw32\4.6.2

Thank your do it.

It seems that libgcc.a is linked on my environment. Is it linked on your environment?

go build -x 2>&1 | tee log
WORK=C:\DOCUME~1\MATTN\LOCALS~1\Temp\go-build560761051
mkdir -p $WORK\github.com\mattn\go-sqlite3\_obj\
cd c:\temp\github\go-mattn\src\github.com\mattn\go-sqlite3
c:\go\pkg\tool\windows_386\cgo.exe -objdir $WORK\github.com\mattn\go-sqlite3\_obj\ -- -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ sqlite3.go sqlite3_windows.go
c:\go\pkg\tool\windows_386\8c.exe -FVw -I $WORK\github.com\mattn\go-sqlite3\_obj\ -I c:\go\pkg\windows_386 -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.8 -DGOOS_windows -DGOARCH_386 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.c
gcc -I . -g -O2 -m32 -mthreads -print-libgcc-file-name
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_main.o -c $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_main.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_export.o -c $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_export.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo2.o -c $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo2.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2.o -c $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.o -c .\sqlite3_windows.c
gcc -I . -g -O2 -m32 -mthreads -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_.o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_main.o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_export.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo2.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.o -lmingwex -lmingw32
c:\go\pkg\tool\windows_386\cgo.exe -objdir $WORK\github.com\mattn\go-sqlite3\_obj\ -dynimport $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_.o -dynout $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_import.c
c:\go\pkg\tool\windows_386\8c.exe -FVw -I $WORK\github.com\mattn\go-sqlite3\_obj\ -I c:\go\pkg\windows_386 -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_import.8 -DGOOS_windows -DGOARCH_386 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_import.c
gcc -I . -g -O2 -m32 -mthreads -o $WORK\github.com\mattn\go-sqlite3\_obj\_all.o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_export.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo2.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.o -Wl,-r -nostdlib -lmingwex -lmingw32 c:/mingw/bin/../lib/gcc/mingw32/4.7.2/libgcc.a
c:\go\pkg\tool\windows_386\8g.exe -o $WORK\github.com\mattn\go-sqlite3\_obj\_go_.8 -p github.com/mattn/go-sqlite3 -D _/c_/temp/github/go-mattn/src/github.com/mattn/go-sqlite3 -I $WORK $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_gotypes.go $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo1.go $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo1.go
c:\go\pkg\tool\windows_386\pack.exe grcP $WORK $WORK\github.com\mattn\go-sqlite3.a $WORK\github.com\mattn\go-sqlite3\_obj\_go_.8 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_import.8 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.8 $WORK\github.com\mattn\go-sqlite3\_obj\_all.o

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

On my environment, libgcc.a is linked correctly.

-lmingw32 c:/mingw/bin/../lib/gcc/mingw32/4.7.2/libgcc.a

from go-sqlite3.

stever avatar stever commented on July 16, 2024

@mattn I haven't spent much time with MinGW to follow these steps constructively. Assuming you are right and the MinGW environment I have is not linking libgcc properly, how do I go about getting the environment you've got running?

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

I haven't spent much time with MinGW to follow these steps constructively. Assuming you are right and the MinGW environment I have is not linking libgcc properly, how do I go about getting the environment you've got running?

I'm getting latest compiler with mingw-get.
But, I hope go-sqlite3 works on your environment which don't need any change...

from go-sqlite3.

stever avatar stever commented on July 16, 2024

I've installed MinGW using minw-get. Now have the same path for the libs C:\MinGW\lib\gcc\mingw32\4.7.2 but the result is the same as before. I still have to use -lgcc_s in sqlite3_windows.go.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Could you please get the result of go build -x ?

My result in in above: #27 (comment)

from go-sqlite3.

stever avatar stever commented on July 16, 2024
C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3>go build -x
WORK=C:\Users\Steve\AppData\Local\Temp\go-build367808483
mkdir -p $WORK\github.com\mattn\go-sqlite3\_obj\
cd C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3
C:\Go\pkg\tool\windows_386\cgo.exe -objdir $WORK\github.com\mattn\go-sqlite3\_ob
j\ -- -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -I $WORK\gi
thub.com\mattn\go-sqlite3\_obj\ sqlite3.go sqlite3_windows.go
C:\Go\pkg\tool\windows_386\8c.exe -FVw -I $WORK\github.com\mattn\go-sqlite3\_obj
\ -I C:\Go\pkg\windows_386 -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.
8 -DGOOS_windows -DGOARCH_386 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.
c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\_cgo_main.o -c $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_ma
in.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\_cgo_export.o -c $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_
export.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\sqlite3.cgo2.o -c $WORK\github.com\mattn\go-sqlite3\_obj\sqli
te3.cgo2.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\sqlite3_windows.cgo2.o -c $WORK\github.com\mattn\go-sqlite3\_
obj\sqlite3_windows.cgo2.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\sqlite3_windows.o -c .\sqlite3_windows.c
gcc -I . -g -O2 -m32 -mthreads -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_.o
 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_main.o $WORK\github.com\mattn\go-sq
lite3\_obj\_cgo_export.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo2.o $
WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2.o $WORK\github.com\ma
ttn\go-sqlite3\_obj\sqlite3_windows.o -lmingwex -lmingw32 -lgcc_s
C:\Go\pkg\tool\windows_386\cgo.exe -objdir $WORK\github.com\mattn\go-sqlite3\_ob
j\ -dynimport $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_.o -dynout $WORK\githu
b.com\mattn\go-sqlite3\_obj\_cgo_import.c
C:\Go\pkg\tool\windows_386\8c.exe -FVw -I $WORK\github.com\mattn\go-sqlite3\_obj
\ -I C:\Go\pkg\windows_386 -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_import
.8 -DGOOS_windows -DGOARCH_386 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_impor
t.c
C:\Go\pkg\tool\windows_386\8g.exe -o $WORK\github.com\mattn\go-sqlite3\_obj\_go_
.8 -p github.com/mattn/go-sqlite3 -D _/C_/Users/Steve/Documents/Go/src/github.co
m/mattn/go-sqlite3 -I $WORK $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_gotypes.
go $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo1.go $WORK\github.com\mattn
\go-sqlite3\_obj\sqlite3_windows.cgo1.go
C:\Go\pkg\tool\windows_386\pack.exe grcP $WORK $WORK\github.com\mattn\go-sqlite3
.a $WORK\github.com\mattn\go-sqlite3\_obj\_go_.8 $WORK\github.com\mattn\go-sqlit
e3\_obj\_cgo_import.8 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.8 $WORK\
github.com\mattn\go-sqlite3\_obj\_cgo_export.o $WORK\github.com\mattn\go-sqlite3
\_obj\sqlite3.cgo2.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2
.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.o

C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3>    

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@stever Ah, sorry, please remove -lgcc_s before build.

from go-sqlite3.

stever avatar stever commented on July 16, 2024
C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3>go build -x
WORK=C:\Users\Steve\AppData\Local\Temp\go-build030297219
mkdir -p $WORK\github.com\mattn\go-sqlite3\_obj\
cd C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3
C:\Go\pkg\tool\windows_386\cgo.exe -objdir $WORK\github.com\mattn\go-sqlite3\_ob
j\ -- -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -I $WORK\gi
thub.com\mattn\go-sqlite3\_obj\ sqlite3.go sqlite3_windows.go
C:\Go\pkg\tool\windows_386\8c.exe -FVw -I $WORK\github.com\mattn\go-sqlite3\_obj
\ -I C:\Go\pkg\windows_386 -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.
8 -DGOOS_windows -DGOARCH_386 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.
c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\_cgo_main.o -c $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_ma
in.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\_cgo_export.o -c $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_
export.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\sqlite3.cgo2.o -c $WORK\github.com\mattn\go-sqlite3\_obj\sqli
te3.cgo2.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\sqlite3_windows.cgo2.o -c $WORK\github.com\mattn\go-sqlite3\_
obj\sqlite3_windows.cgo2.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\sqlite3_windows.o -c .\sqlite3_windows.c
gcc -I . -g -O2 -m32 -mthreads -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_.o
 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_main.o $WORK\github.com\mattn\go-sq
lite3\_obj\_cgo_export.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo2.o $
WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2.o $WORK\github.com\ma
ttn\go-sqlite3\_obj\sqlite3_windows.o -lmingwex -lmingw32 -lgcc_s
C:\Go\pkg\tool\windows_386\cgo.exe -objdir $WORK\github.com\mattn\go-sqlite3\_ob
j\ -dynimport $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_.o -dynout $WORK\githu
b.com\mattn\go-sqlite3\_obj\_cgo_import.c
C:\Go\pkg\tool\windows_386\8c.exe -FVw -I $WORK\github.com\mattn\go-sqlite3\_obj
\ -I C:\Go\pkg\windows_386 -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_import
.8 -DGOOS_windows -DGOARCH_386 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_impor
t.c
C:\Go\pkg\tool\windows_386\8g.exe -o $WORK\github.com\mattn\go-sqlite3\_obj\_go_
.8 -p github.com/mattn/go-sqlite3 -D _/C_/Users/Steve/Documents/Go/src/github.co
m/mattn/go-sqlite3 -I $WORK $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_gotypes.
go $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo1.go $WORK\github.com\mattn
\go-sqlite3\_obj\sqlite3_windows.cgo1.go
C:\Go\pkg\tool\windows_386\pack.exe grcP $WORK $WORK\github.com\mattn\go-sqlite3
.a $WORK\github.com\mattn\go-sqlite3\_obj\_go_.8 $WORK\github.com\mattn\go-sqlit
e3\_obj\_cgo_import.8 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.8 $WORK\
github.com\mattn\go-sqlite3\_obj\_cgo_export.o $WORK\github.com\mattn\go-sqlite3
\_obj\sqlite3.cgo2.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2
.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.o

C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3>    

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

It seems not removed -lgcc_s.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

I thought I had done, but you're right. Trying again...

C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3>go build -x
WORK=C:\Users\Steve\AppData\Local\Temp\go-build397327063
mkdir -p $WORK\github.com\mattn\go-sqlite3\_obj\
cd C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3
C:\Go\pkg\tool\windows_386\cgo.exe -objdir $WORK\github.com\mattn\go-sqlite3\_ob
j\ -- -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -I $WORK\gi
thub.com\mattn\go-sqlite3\_obj\ sqlite3.go sqlite3_windows.go
C:\Go\pkg\tool\windows_386\8c.exe -FVw -I $WORK\github.com\mattn\go-sqlite3\_obj
\ -I C:\Go\pkg\windows_386 -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.
8 -DGOOS_windows -DGOARCH_386 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.
c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\_cgo_main.o -c $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_ma
in.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\_cgo_export.o -c $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_
export.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\sqlite3.cgo2.o -c $WORK\github.com\mattn\go-sqlite3\_obj\sqli
te3.cgo2.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\sqlite3_windows.cgo2.o -c $WORK\github.com\mattn\go-sqlite3\_
obj\sqlite3_windows.cgo2.c
gcc -I . -g -O2 -m32 -mthreads -I. -fno-stack-check -fno-stack-protector -mno-st
ack-arg-probe -I $WORK\github.com\mattn\go-sqlite3\_obj\ -o $WORK\github.com\mat
tn\go-sqlite3\_obj\sqlite3_windows.o -c .\sqlite3_windows.c
gcc -I . -g -O2 -m32 -mthreads -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_.o
 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_main.o $WORK\github.com\mattn\go-sq
lite3\_obj\_cgo_export.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo2.o $
WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2.o $WORK\github.com\ma
ttn\go-sqlite3\_obj\sqlite3_windows.o -lmingwex -lmingw32
C:\Go\pkg\tool\windows_386\cgo.exe -objdir $WORK\github.com\mattn\go-sqlite3\_ob
j\ -dynimport $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_.o -dynout $WORK\githu
b.com\mattn\go-sqlite3\_obj\_cgo_import.c
C:\Go\pkg\tool\windows_386\8c.exe -FVw -I $WORK\github.com\mattn\go-sqlite3\_obj
\ -I C:\Go\pkg\windows_386 -o $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_import
.8 -DGOOS_windows -DGOARCH_386 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_impor
t.c
C:\Go\pkg\tool\windows_386\8g.exe -o $WORK\github.com\mattn\go-sqlite3\_obj\_go_
.8 -p github.com/mattn/go-sqlite3 -D _/C_/Users/Steve/Documents/Go/src/github.co
m/mattn/go-sqlite3 -I $WORK $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_gotypes.
go $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3.cgo1.go $WORK\github.com\mattn
\go-sqlite3\_obj\sqlite3_windows.cgo1.go
C:\Go\pkg\tool\windows_386\pack.exe grcP $WORK $WORK\github.com\mattn\go-sqlite3
.a $WORK\github.com\mattn\go-sqlite3\_obj\_go_.8 $WORK\github.com\mattn\go-sqlit
e3\_obj\_cgo_import.8 $WORK\github.com\mattn\go-sqlite3\_obj\_cgo_defun.8 $WORK\
github.com\mattn\go-sqlite3\_obj\_cgo_export.o $WORK\github.com\mattn\go-sqlite3
\_obj\sqlite3.cgo2.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.cgo2
.o $WORK\github.com\mattn\go-sqlite3\_obj\sqlite3_windows.o

C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3>    

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

ok, -lgcc_s is removed, and it seems that you don't get fail to build. :)

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

When the build error happen? building example/main.go ? If it so, please show me the result of go build -x main.go.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

No build error. Just errors when running. Here's the output:

C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3\example>go run main.go
# command-line-arguments
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __moddi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __moddi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __moddi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __moddi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __moddi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __divdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __moddi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __moddi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __umoddi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __udivdi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __umoddi3: not defined
C:\Users\Steve\AppData\Local\Temp\go-build545176583/github.com/mattn/go-sqlite3.a(sqlite3_windows.)(.text): __udivdi3: not defined
too many errors

C:\Users\Steve\Documents\Go\src\github.com\mattn\go-sqlite3\example>    

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

If use #cgo LDFLAGS: -lgcc -lgcc_s -lmingwex, it can work ?

from go-sqlite3.

stever avatar stever commented on July 16, 2024

Actually no - same errors. Still, if I use #cgo LDFLAGS: -lmingwex -lmingw32 -lgcc_s it does. Seems interesting.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

<g> OMG

from go-sqlite3.

stever avatar stever commented on July 16, 2024

Also built with #cgo LDFLAGS: -lmingwex -lmingw32 -lgcc -lgcc_s and the example doesn't work. It does work if I remove -lgcc to have #cgo LDFLAGS: -lmingwex -lmingw32 -lgcc_s

I'm using the command go install though and I'm not sure if that hides build errors. There was no ouput.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Hmm, maybe I must write __divdi3 on my code.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

The example even works for me if all I use is #cgo LDFLAGS: -lgcc_s

from go-sqlite3.

stever avatar stever commented on July 16, 2024

I'm not so interested in having sqlite3 statically compiled over having it has a DLL dependency. Initially I made a fork and included the following info to help build 32-bit and 64-bit sqlite3.dll on Windows. Perhaps it is useful.

Download the SQLite amalgamation source
and compile using MinGW.

64-bit:

gcc -shared -DWIN64 -DNDEBUG -D_WINDOWS -D_USRDLL -DNO_TCL -D_CRT_SECURE_NO_DEPRECATE -DTHREADSAFE=1 -DTEMP_STORE=1 -DSQLITE_MAX_EXPR_DEPTH=0 -m64 -I. shell.c sqlite3.c -o sqlite3.dll -Wl,--out-implib,sqlite3.a

32-bit:

gcc -shared -DWIN32 -D_WINDOWS -D_USRDLL -DNO_TCL -D_CRT_SECURE_NO_DEPRECATE -DTHREADSAFE=1 -DTEMP_STORE=1 -DSQLITE_MAX_EXPR_DEPTH=0 -m32 -I. shell.c sqlite3.c -o sqlite3.dll -Wl,--out-implib,sqlite3.a
  • Copy sqlite3.dll to a location included in LIBRARY_PATH.
  • Copy sqlite3.h and sqlite3ext.h to a location included in C_INCLUDE_PATH.

See Compiling SQLite for Windows (64-bit)

from go-sqlite3.

stever avatar stever commented on July 16, 2024

I had struggled without the above info to make 32-bit and 64-bit versions of the sqlite3.dll which I required.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Probably, whether compiler use divdi3 or not, is related on CPU. On my
environment, the optimization is disabled maybe. And probably your is
enabled. i.e. divdi3 is not linked from libgcc.a on my environment,
And libgcc_s.a is linked not properly(compiler isn't expected).

On 12/10/12, Steven Robertson [email protected] wrote:

I had struggled without the above info to make 32-bit and 64-bit versions of
the sqlite3.dll which I required.


Reply to this email directly or view it on GitHub:
#27 (comment)

  • Yasuhiro Matsumoto

from go-sqlite3.

stever avatar stever commented on July 16, 2024

I've only tested using Windows in VMware for 32-bit, though hosted on systems with both 64-bit Intel and AMD CPU.

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

I'll try to build without optimization of CPU arch in next time.

On 12/11/12, Steven Robertson [email protected] wrote:

I've only tested using Windows in VMware for 32-bit, though hosted on
systems with both 64-bit Intel and AMD CPU.


Reply to this email directly or view it on GitHub:
#27 (comment)

  • Yasuhiro Matsumoto

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

minix let me know answer.

https://groups.google.com/d/msg/golang-nuts/5If6AoWD_mU/jjBq8XvBTUgJ

from go-sqlite3.

stever avatar stever commented on July 16, 2024

Ah, a resolved issue in Go. I'm not keen to compile Go on Windows, though maybe it's easy... I'll give it a go.

from go-sqlite3.

stever avatar stever commented on July 16, 2024

Actually, building tip from source is no problem. Just need Mercurial installed... and it works!

No need for the -lgcc_s flag at all with Go source tip revision, on either 32-bit Windows or 64-bit Windows.

Thanks for the resolution.

from go-sqlite3.

matrixik avatar matrixik commented on July 16, 2024

Trying install Go from source, fails on compilation time and even that it look like Go working I couldn't go get some packages (but go get github.com/gorilla/mux worked o_O ):

d:\Dropbox\_Politechnika>go get code.google.com/p/go.crypto/scrypt
package code.google.com/p/go.crypto/scrypt: Get https://code.google.com/p/go/source/checkout?repo=crypto: dial tcp 173.194.65.138:443: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

d:\Dropbox\_Politechnika>go get thegoods.biz/httpbuf
package thegoods.biz/httpbuf: unrecognized import path "thegoods.biz/httpbuf"

Move back to Windows installer and go get working again

But when I have Go installed from source go-sqlite3 worked OK without -lgcc_s flag.

I would leave that issue open until Go stable release will fix it (next year?).

Best regards

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Did you make sure this issue on hg tip?

from go-sqlite3.

matrixik avatar matrixik commented on July 16, 2024

Working without problems on tip.

Best regards,
Dobrosław Żybort

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

@matrixik thank you! is this closable?

from go-sqlite3.

matrixik avatar matrixik commented on July 16, 2024

Yes.
But maybe you can add some info to readme that there can be problems with Go 1.0 on Windows with link to this issue (or specific post showing how to fix it).

Best regards,
Dobrosław Żybort

from go-sqlite3.

mattn avatar mattn commented on July 16, 2024

Thank you all.

from go-sqlite3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.