Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install without gcc (not possible) #212

Closed
techtonik opened this issue Jun 17, 2015 · 52 comments
Closed

Install without gcc (not possible) #212

techtonik opened this issue Jun 17, 2015 · 52 comments

Comments

@techtonik
Copy link

Is it possible to use the library in Go without recompiling the binaries?lxc/incus#762 (comment)

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?

@mattn
Copy link
Owner

mattn commented Jun 17, 2015

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.

@techtonik
Copy link
Author

@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)

@mattn
Copy link
Owner

mattn commented Jun 18, 2015

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

@techtonik
Copy link
Author

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

@mattn
Copy link
Owner

mattn commented Jun 18, 2015

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.

@techtonik
Copy link
Author

And I answered to you in #212 (comment) We are going circles.

@drewwells
Copy link

@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.

@arulrajalivi
Copy link

@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%

@drewwells
Copy link

@arulrajalivi what OS are you using?

@arulrajalivi
Copy link

Windows 64

@arulrajalivi
Copy link

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
Copy link

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

@arulrajalivi
Copy link

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

@drewwells
Copy link

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"

@arulrajalivi
Copy link

$ 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
Copy link

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.

@mattn
Copy link
Owner

mattn commented Jun 26, 2015

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

@kfsone
Copy link

kfsone commented Nov 9, 2015

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?

@mattn
Copy link
Owner

mattn commented Nov 9, 2015

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

@smeraji
Copy link

smeraji commented Feb 17, 2016

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?

@mattn
Copy link
Owner

mattn commented Feb 17, 2016

go get -u github.com/mattn/go-sqlite3

@smeraji
Copy link

smeraji commented Feb 17, 2016

so in windows I get "exec gcc executable %PATH%", it's the same problme you guys discussed above I just do not understand how you resolved it

I can get the package but i can not create the binary because I do not have GCC.

@mattn
Copy link
Owner

mattn commented Feb 17, 2016

go-sqlite3 is cgo package, so you need to install gcc.

@smeraji
Copy link

smeraji commented Feb 17, 2016

So in windows, I have to install Cygwin, build the binary and put in "GOROOT/PKG", is that what you mean?

@mattn
Copy link
Owner

mattn commented Feb 17, 2016

  1. install http://msys2.github.io/
  2. launch mingw64_shell.bat or mingw32_shell.bat
  3. go get -u github.com/mattn/go-sqlite3

@smeraji
Copy link

smeraji commented Feb 17, 2016

I still get the exact same error after following the steps you mentioned
image

@mattn
Copy link
Owner

mattn commented Feb 17, 2016

pacman -S mingw-w64-x86_64-gcc

@DominoTree
Copy link

If it helps anyone, by default, msys2's Pacman seems to install gcc into C:\msys64\mingw64\bin so you'll need to add that directory to your environment PATH variable and restart your programs before gcc will work.

@techtonik techtonik changed the title Using without gcc Using without gcc (not possible) Mar 31, 2016
@mattn
Copy link
Owner

mattn commented Mar 31, 2016

FYI, This is Not installable not Not using

@mattn mattn changed the title Using without gcc (not possible) Install without gcc (not possible) Mar 31, 2016
@techtonik
Copy link
Author

@mattn the users of this extension are developers, and they need to install it to use it first, and this is impossible without gcc. It is my understanding how Go stuff works. What do you mean by using if that's not the case?

@mattn
Copy link
Owner

mattn commented Mar 31, 2016

If you install go-sqlite3 with go install, you can find $GOPATH/pkg/${GOOS}_${GOARCH}/github.com/mattn/go-sqlite3.a . This mean that you don't need to re-compile it if you don't update go runtime. And you can build another package using go-sqlite3 without recompiling go-sqlite3. Then I mean not installable but can use. For example, you can see debian packages that is built as binary package. But go-sqlite3 still is not published as debian package.

@techtonik
Copy link
Author

This says that go install compiles code too:
https://stackoverflow.com/questions/24878737/what-is-the-difference-between-go-get-and-go-install

I am not able to validate this claim now, because:

>go get github.com/mattn/go-sqlite
# cd .; git clone https://github.com/mattn/go-sqlite E:\go\src\github.com\mattn\go-sqlite
Cloning into 'E:\go\src\github.com\mattn\go-sqlite'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
package github.com/mattn/go-sqlite: exit status 128

I guess I had enough of yak shaving for this issue. Feel free to close until better time.

@mattn
Copy link
Owner

mattn commented Mar 31, 2016

go get is not same as go install

@mattn
Copy link
Owner

mattn commented Mar 31, 2016

As I said in above, if you compile go-sqlite3.a with go install at once, you can uninstall gcc compiler.

@tonymtz
Copy link

tonymtz commented Apr 2, 2016

I have the same problem on ubuntu 14.04.4 LTS, I tried this:

$ git clone https://github.com/mattn/go-sqlite3
Cloning into 'go-sqlite3'...
remote: Counting objects: 1112, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 1112 (delta 0), reused 0 (delta 0), pack-reused 1110
Receiving objects: 100% (1112/1112), 8.27 MiB | 4.93 MiB/s, done.
Resolving deltas: 100% (588/588), done.
Checking connectivity... done.

$ go install github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
exec: "gcc": executable file not found in $PATH

Any suggestion?

@DominoTree
Copy link

sudo apt-get install build-essential

@dibakarmitra
Copy link

having the same problem "exec: "gcc": executable file not found in $PATH" :(

@mattn
Copy link
Owner

mattn commented Aug 5, 2016

@mitradibakar please read all of comments in above.

@mattn mattn closed this as completed Aug 5, 2016
@dibakarmitra
Copy link

dibakarmitra commented Aug 5, 2016

Its working fine now windows thanks to @mattn and "tdm64-gcc-5.1.0-2.exe" happy coding :)

@tongxiaofeng
Copy link

"tdm64-gcc-5.1.0-2.exe" is the solution.

@pangliang
Copy link

pangliang commented Jan 4, 2017

apt-cyg install mingw64-x86_64-gcc-g++
env CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="x86_64-w64-mingw32-gcc" \
    go get github.com/mattn/go-sqlite3

In Cygwin will be fine.

@msaron
Copy link

msaron commented Jan 18, 2017

Here are the step by step instructions.

  1. Download and install "tdm64-gcc-5.1.0-2.exe" from http://tdm-gcc.tdragon.net/download.
  2. Go to Program Files and click on "MinGW Command Prompt". This will start a DOS prompt with the correct environment for using MinGW with GCC.
  3. Within this DOS prompt window, navigate to your GOPATH. For example, I went to C:\go-apps.
  4. Enter the following commands: go get -u github.com/mattn/go-sqlite3. Then enter go install github.com/mattn/go-sqlite3
  5. You are done! go-sqlite3 is now installed and ready for use.

@sanoanalytics
Copy link

msaron - Thank You!

@sedentaryOne
Copy link

perfect help! Thanks, everyone.

@Xorton
Copy link

Xorton commented Mar 5, 2018

But if you install go-sqlite3 with go install github.com/mattn/go-sqlite, you don't need gcc.

After installing i still need gcc.

go build
C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exec: "gcc": executable file not found in %PATH%

@AndreKR
Copy link

AndreKR commented Apr 14, 2018

I would like to mention that this package really only needs a GCC in the PATH. No libraries, no special command prompts, nothing else.

The problem with most CGO packages is that the README says "needs GCC", but actually means something like "needs a certain version of GCC from the 32-bit build of Mingw-w64 and also this library, which you have to compile with make (but not GNU make, the other one) in an upside-down Visual Studio Command Prompt with CYGWIN_PATH_MANGLING set to MORE_MAGIC which is only available on Windows ME".

That is why I usually give up and use a different package when I see import "C", which is exactly what I did with go-sqlite3. I went through a whole zoo of embedded databases before I found out that you really just need any GCC, be it MSYS2 or TDM or Cygwin, and you just have to have it in your PATH.

@cengiz7
Copy link

cengiz7 commented Jul 2, 2018

for linux > sudo apt install gcc
then > go get -u github.com/mattn/go-sqlite3

@vkroll
Copy link

vkroll commented Oct 10, 2018

I had the same problem on ubuntu:
4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
the problem seemed that ubuntu has no gcc-5 installed per default...

go install github.com/mattn/go-sqlite3
exec: "gcc-5": executable file not found in $PATH

go get -v github.com/mattn/go-sqlite3
exec: "gcc-5": executable file not found in $PATH

$sudo apt install gcc-5

then it worked

@hima-del
Copy link

I am using windows machine and I am getting error like

github.com/mattn/go-sqlite3

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

@AndreKR
Copy link

AndreKR commented Jan 21, 2021

Which GCC have you installed and where?

@dibakarmitra
Copy link

Which GCC have you installed and where?

https://jmeubank.github.io/tdm-gcc/

Is working fine on windows 10 64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests