Skip to content
New issue

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

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

Already on GitHub? # to your account

Compile to arm cpu error #242

Closed
dylanlyu opened this issue Sep 29, 2015 · 8 comments
Closed

Compile to arm cpu error #242

dylanlyu opened this issue Sep 29, 2015 · 8 comments

Comments

@dylanlyu
Copy link

C source files not allowed when not using cgo or SWIG: sqlite3-binding.c

i try export CGO_ENABLED=1 but

runtime/cgo

clang: error: argument unused during compilation: '-mno-thumb'

What ideas can be compile successfully???

@mikemackintosh
Copy link

👍 on OSX (go version go1.5.2 darwin/amd64) building for Linux

$ CGO_ENABLED=1 GOOS=linux go build -v main.go
runtime
errors
sync/atomic
math
unicode/utf8
sort
unicode
sync
encoding
runtime/cgo
io
syscall
# runtime/cgo
ld: unknown option: --build-id=none
clang: error: linker command failed with exit code 1 (use -v to see invocation)
internal/singleflight
container/list

@ZhouLiHai
Copy link

ZhouLiHai commented Apr 27, 2016

Hi.i got this problem too.
Did you fix this problem finally?How?

@mattn
Copy link
Owner

mattn commented Apr 27, 2016

you compiler have --build-id flag?

@ZhouLiHai
Copy link

CC=arm-none-linux-gnueabi-gcc
Finally, Use this flag to setup you own compiler, not use Clang.

@mattn
Copy link
Owner

mattn commented Apr 28, 2016

go-sqlite3 doesn't require --build-id flag but seems go require it.

@TankTheFrank
Copy link

In case someone else stumbles on this as I did here is the complete info:

  • to cross compile you need the cross compiler. I am targeting hard float so mine is arm-linux-gnueabihf-gcc/arm-linux-gnueabihf-g++ . Get it installed - for linux there are official packages, for mac search around there are plenty of resources on how to get/install the gcc toolchain targeting arm
  • add the crosscompiler toolchain to the path
  • to build your go program you need to use the above compiler. Just run:
env CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \
    CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 \
    go build -v main.go

gjrtimmer added a commit to gjrtimmer/go-sqlite3 that referenced this issue May 26, 2018
Compile Section Closes mattn#175
Compile Section Closes mattn#201
Compile Section Closes mattn#206
Compile Section Closes mattn#404
Compile Section Closes mattn#217
Compile Section Closes mattn#224
Compile Section Closes mattn#234
Compile Section Closes mattn#242
Feature table Closes mattn#255
Description Section Closes mattn#232
Golang:1.6 not supported Closes mattn#272
Golang:1.5 not supported + compilation section Closes mattn#283
usleep Implemented Closes mattn#285
FAQ Section Closes mattn#289
Compile Section closes mattn#295
FAQ Section Closes mattn#305
PR339 Closes mattn#318 mattn#321
Compilation Section Closes mattn#341
PR407 Closes mattn#364
Feature `sqlite_vtable` Closes mattn#393
Compile Section Closes mattn#416
sqlite_trace feature Closes mattn#433
Compilation Section Closes mattn#435
Compilation Section Closes mattn#443
Golang:1.6 Not Supported Closes mattn#445
Compilation Section Closes mattn#451
Compilation Section Closes mattn#467
Compilation Section Closes mattn#491
Compilation Section Closes mattn#495
Compilation Section Closes mattn#505
Compilation Section Closes mattn#557
Compilation Section Closes mattn#560
@mattn mattn closed this as completed in c9394b1 May 27, 2018
@vrachtwagen
Copy link

Chipping in, for those targeting the arm64 arch out of linux distro. Here are the commands:

sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

env CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -v -o arm64

@otoolep
Copy link
Contributor

otoolep commented Mar 11, 2024

FWIW I have a script that compiles rqlite for a bunch of CPU architectures here: https://github.com/rqlite/rqlite/blob/master/scripts/package.sh

These are the needed cross-compilers for Linux:

https://github.com/rqlite/rqlite/blob/master/.circleci/images/circleci-primary/Dockerfile

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

No branches or pull requests

7 participants