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

cross-compile mattn/go-sqlite3 --targets=linux/arm #504

Closed
zeevikal opened this issue Dec 7, 2017 · 6 comments
Closed

cross-compile mattn/go-sqlite3 --targets=linux/arm #504

zeevikal opened this issue Dec 7, 2017 · 6 comments
Assignees
Labels

Comments

@zeevikal
Copy link

zeevikal commented Dec 7, 2017

Im trying to compile mattn/go-sqlite3 to linux/arm.
I run:
sudo docker run karalabe/xgo-latest github.com/mattn/go-sqlite3 --targets=linux/arm
I get:

Fetching main repository github.com/mattn/go-sqlite3...
github.com/mattn/go-sqlite3 (download)
Fetching https://golang.org/x/net/context?go-get=1
Parsing meta tags from https://golang.org/x/net/context?go-get=1 (status code 200)
get "golang.org/x/net/context": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/context?go-get=1
get "golang.org/x/net/context": verifying non-authoritative meta tag
Fetching https://golang.org/x/net?go-get=1
Parsing meta tags from https://golang.org/x/net?go-get=1 (status code 200)
golang.org/x/net (download)
Assembling toolchain for android-16/arm...
Bootstrapping android-16/arm...
Compiling for android-16/arm...
Assembling toolchain for android-16/386...
Bootstrapping android-16/386...
Compiling for android-16/386...
/tmp/tmp.izDbZRL94v/go-sqlite3.i:1: Error: Syntax error in input(1).

what am I doing wrong? thanks

@mattn
Copy link
Owner

mattn commented Dec 7, 2017

go-sqlite3 doesn't use swig (file extension .i). may be it is not an issue of go-sqlite3.

@zeevikal
Copy link
Author

zeevikal commented Dec 7, 2017

can you advise me please, what should I do?
I want to compile github.com/mattn/go-sqlite3 to Arm6.
thank you

@mattn
Copy link
Owner

mattn commented Dec 8, 2017

Sorry, I don't have arm6 and not well to know karalabe/xgo-latest.

@jacentsao
Copy link

I just have a test and it's okay to use xgo build linux/arm. My go env is

go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Eveee/Storage/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w4/75xgx41n2bb7mm3m0dxbp0d40000gn/T/go-build381488672=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

and build process log

github.com/mattn/go-sqlite3  master ✗                                                                                                                                     56d ⚑ ◒  ⍉
▶ xgo --targets=linux/arm  .
Checking docker installation...
Client:
 Version:      17.09.1-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:22:25 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.09.1-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:28:28 2017
 OS/Arch:      linux/amd64
 Experimental: true

Checking for required docker image karalabe/xgo-latest... found.
Cross compiling github.com/mattn/go-sqlite3...
Building locally github.com/mattn/go-sqlite3...
Bootstrapping linux/arm-5...
Compiling for linux/arm-5...
Cleaning up Go runtime for linux/arm-5...
Cleaning up build environment...```

@gjrtimmer
Copy link
Collaborator

@zeevikal Current master has no problem with cross-compile

To compile for ARM6 use:

GOARM=6 GOARCH=arm go build -a -v .

Verification:

gtimmert@Aeris:~/Projects/go/src/go-sqlite3$ GOARM=6 GOARCH=arm go build -a -v .
errors
internal/race
runtime/internal/sys
unicode/utf8
sync/atomic
runtime/internal/atomic
math
unicode
internal/testlog
runtime
strconv
sync
io
reflect
syscall
time
internal/poll
os
sort
fmt
context
database/sql/driver
database/sql
go-sqlite3
gtimmer@Aeris:~/Projects/go/src/go-sqlite3$

@gjrtimmer gjrtimmer self-assigned this May 30, 2018
@ripply
Copy link

ripply commented Nov 19, 2018

I ran into this problem on a separate project and found a solution.

/tmp/tmp.izDbZRL94v/go-sqlite3.i:1: Error: Syntax error in input(1).

Here is what xgo generates

%module go-sqlite3
%{
#include "go-sqlite3.h"
%}
%pragma(java) jniclasscode=%{
static {
System.loadLibrary("go-sqlite3");
}
%}
%include "go-sqlite3.h"

The problem is the dash in %module go-sqlite3

The solution is to rename the project or add -out projectwithoutdash to xgo

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

No branches or pull requests

5 participants