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

Install without gcc (not possible)

Open techtonik opened this issue 11 years ago • 53 comments

Is it possible to use the library in Go without recompiling the binaries?https://github.com/lxc/lxd/issues/762#issuecomment-112463214

I mean is it possible to compile binary pieces of SQLite needed be go-sqlite3 and ship them in separate repository, so that only Go itself can be used to assemble the final product together? Maybe Go already provides some helpers/tools to do that?

techtonik avatar Jun 17 '15 12:06 techtonik

go-sqlite3 is cgo package. so if you want to build app using go-sqlite3, you need gcc. But if you install go-sqlite3 with go install github.com/mattn/go-sqlite, you don't need gcc.

mattn avatar Jun 17 '15 14:06 mattn

@mattn the repository github.com/mattn/go-sqlite doesn't exists, and go install github.com/mattn/go-sqlite3 doesn't work too:

C:\ledis>go install github.com/mattn/go-sqlite3
can't load package: package github.com/mattn/go-sqlite3: cannot find package "github.com/mattn/go-sqlite3" in any of:
        C:\Program Files\Dev\Go\src\github.com\mattn\go-sqlite3 (from $GOROOT)
        C:\ledis\src\github.com\mattn\go-sqlite3 (from $GOPATH)

techtonik avatar Jun 17 '15 22:06 techtonik

once go get github.com/mattn/go-sqlite3 and do go install github.com/mattn/go-sqlite3.

mattn avatar Jun 18 '15 00:06 mattn

C:\ledis\src>go get github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
exec: "gcc": executable file not found in %PATH%

techtonik avatar Jun 18 '15 07:06 techtonik

As I said in above:

go-sqlite3 is cgo package. so if you want to build app using go-sqlite3, you need gcc. But if you install go-sqlite3 with go install github.com/mattn/go-sqlite, you don't need gcc.

mattn avatar Jun 18 '15 07:06 mattn

And I answered to you in https://github.com/mattn/go-sqlite3/issues/212#issuecomment-112969533 We are going circles.

techtonik avatar Jun 18 '15 07:06 techtonik

@techtonik once go-sqlite3 is installed, you no longer need gcc. However, you need the compiled package in your $GOPATH/pkg to do this. To do so, you need gcc to build the C dependencies of this project. ie. $GOPATH/pkg/darwin_amd64/github.com/mattn/go-sqlite3.a.

You could probably compile the archive file elsewhere and put it in the $GOPATH to forego gcc. This isn't guaranteed to work, it's much easier to compile the final program and put the binary on the system with no gcc.

drewwells avatar Jun 24 '15 02:06 drewwells

@drewwells: the problem is I am able to go get the package but not able to build/install it. Its complaining about "gcc"

github.com/mattn/go-sqlite3

exec: "gcc": executable file not found in %PATH%

arulrajalivi avatar Jun 25 '15 15:06 arulrajalivi

@arulrajalivi what OS are you using?

drewwells avatar Jun 25 '15 15:06 drewwells

Windows 64

arulrajalivi avatar Jun 25 '15 16:06 arulrajalivi

from cygwin if I try which gcc I get $ gcc --version gcc (GCC) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

arulrajalivi avatar Jun 25 '15 16:06 arulrajalivi

followed this link to install gcc : http://preshing.com/20141108/how-to-install-the-latest-gcc-on-windows/

arulrajalivi avatar Jun 25 '15 16:06 arulrajalivi

getting this from cygwin, so trying to see what to set in the %PATH% $which gcc /usr/bin/gcc

arulrajalivi avatar Jun 25 '15 16:06 arulrajalivi

Inside a cygwin window, see what go env says

CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

drewwells avatar Jun 25 '15 16:06 drewwells

$ go env set GOARCH=amd64 set GOBIN=$GOROOT\bin set GOCHAR=6 set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\Projects\Cloud Solutions
set GORACE= set GOROOT=C:\Go set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set CC=gcc set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 set CXX=g++ set CGO_ENABLED=1

arulrajalivi avatar Jun 25 '15 16:06 arulrajalivi

after adding C:\MinGW\bin, I am getting # github.com/mattn/go-sqlite3 cc1.exe: sorry, unimplemented: 64-bit mode not compiled in. Trying to install the 64 bit version of MinGW but having trouble with that.

arulrajalivi avatar Jun 25 '15 19:06 arulrajalivi

as the message, you need to install 64bit gcc.

mattn avatar Jun 26 '15 00:06 mattn

Early on mattn suggested that you could just "go install ..." but said "go-sqlite" instead of "go-sqlite3". Was this significant?

Or is mattn's last comment, that you need gcc, the absolute truth? Is there a way to install this API without gcc under windows or not?

kfsone avatar Nov 09 '15 00:11 kfsone

Ah, it's my fault. :s/go-sqlite/go-sqlite3/g

mattn avatar Nov 09 '15 01:11 mattn

I have the exact same the problem in windows and I do not understand how Mattm last command solved the problem? what would be the compele command for go insrall?

smeraji avatar Feb 17 '16 05:02 smeraji