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

Error building go app : undefined: SQLiteConn #327

Closed
Murf opened this issue Sep 14, 2016 · 18 comments
Closed

Error building go app : undefined: SQLiteConn #327

Murf opened this issue Sep 14, 2016 · 18 comments

Comments

@Murf
Copy link

Murf commented Sep 14, 2016

....\github.com\mattn\go-sqlite3\tracecallback_noimpl.go:7: undefined: SQLiteConn

OS: Windows 10 Pro 64
c++ compiler framework: MinGW64

@mattn
Copy link
Owner

mattn commented Sep 14, 2016

can't reproduce this. what is different from general situation?

@Murf
Copy link
Author

Murf commented Sep 14, 2016

I have used the test code under "Quickstart" from https://github.com/go-gorp/gorp
I have go version go1.7.1 windows/amd64

I used "github.com/mattn/go-sqlite3" and it build and installed fine

Any other info you need Matt?

This is the error at the end of "go build test.go"
"#" github.com/mattn/go-sqlite3
....\github.com\mattn\go-sqlite3\tracecallback_noimpl.go:7: undefined: SQLiteConn

@mattn
Copy link
Owner

mattn commented Sep 14, 2016

please try with go build -x on $GOPATH/github.com/mattn/go-sqlite3

@Murf
Copy link
Author

Murf commented Sep 14, 2016

@mattn
Copy link
Owner

mattn commented Sep 14, 2016

What about go env ?

@Murf
Copy link
Author

Murf commented Sep 14, 2016

D:\Working\go\src\github.com\mattn\go-sqlite3>go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Working\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\brettm\AppData\Local\Temp\go-build709739654=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1

@mattn
Copy link
Owner

mattn commented Sep 14, 2016

I used "github.com/mattn/go-sqlite3" and it build and installed fine

But not? Is this an issue related on tests?

@Murf
Copy link
Author

Murf commented Sep 14, 2016

D:\Working\go\src\github.com>
D:\Working\go\src\github.com>rmdir /s mattn
mattn, Are you sure (Y/N)? y
D:\Working\go\src\github.com>go get github.com/mattn/go-sqlite3
D:\Working\go\src\github.com>

That is what I meant Matt, I did not get any errors when I installed it

@mattn
Copy link
Owner

mattn commented Sep 14, 2016

Okay, then what is remaining issue?

@Murf
Copy link
Author

Murf commented Sep 14, 2016

Matt, I think if is a cross compiler issue
this works:
go build -v test.go

this does not:
D:\Working\go\src\local\syslog-connector-go>set GOARCH=amd64

D:\Working\go\src\local\syslog-connector-go>set GOOS=linux

D:\Working\go\src\local\syslog-connector-go>go build -v test.go
...
log
database/sql
github.com/mattn/go-sqlite3
gopkg.in/gorp.v1
(#) github.com/mattn/go-sqlite3
....\github.com\mattn\go-sqlite3\tracecallback_noimpl.go:7: undefined: SQLiteConn

@Murf
Copy link
Author

Murf commented Sep 14, 2016

Further..
I used set CGO_ENABLED=1
and now have this problem (which seems to have progressed at least)

D:\Working\go\src\local\syslog-connector-go>go build -v test.go
runtime/internal/sys
runtime/internal/atomic
...
strconv
(#) runtime/cgo
C:\Go\src\runtime\cgo\gcc_linux_amd64.c: In function '_cgo_sys_thread_start':
C:\Go\src\runtime\cgo\gcc_linux_amd64.c:61:2: error: unknown type name 'sigset_t'
sigset_t ign, oset;
^~~~~~~~
C:\Go\src\runtime\cgo\gcc_linux_amd64.c:66:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
sigfillset(&ign);
^~~~~~~~~~
C:\Go\src\runtime\cgo\gcc_linux_amd64.c:61:16: error: unused variable 'oset' [-Werror=unused-variable]
sigset_t ign, oset;
^~~~
cc1.exe: all warnings being treated as errors
regexp/syntax
...
database/sql
gopkg.in/gorp.v1

@Murf
Copy link
Author

Murf commented Sep 14, 2016

I think it is because cgo not supported for cross compilation in Go, I will move my dev environment to a linux container.
Thanks Matt, please close

@Murf Murf closed this as completed Sep 14, 2016
@andrejvanderzee
Copy link

andrejvanderzee commented Oct 26, 2016

On Linux I am unable to compile without cgo. Is there any solution to this?

$ CGO_ENABLED=0 go build --ldflags '-extldflags "-static"' -ldflags '-s' -a -installsuffix cgo
# github.com/mattn/go-sqlite3
../../../../github.com/mattn/go-sqlite3/tracecallback_noimpl.go:7: undefined: SQLiteConn

@mattn
Copy link
Owner

mattn commented Oct 26, 2016

go-sqlite3 require ENABLE_CGO=1

@nkumar15
Copy link

to be more clear CGO_ENABLED=1 is needed.

@codenoid
Copy link

codenoid commented Oct 15, 2019

using ubuntu 18.04

command :

CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -o app.exe app.go

error :

gcc: error: unrecognized command line option ‘-mthreads’; did you mean ‘-pthread’?

@rittneje
Copy link
Collaborator

@codenoid You need to set CC to a valid Windows cross compiler. By default you are using the one for your host (Linux).

@codenoid
Copy link

@rittneje yea, just successfully compile my application in target host (windows)

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

6 participants