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

go build error #491

Closed
yincongcyincong opened this Issue Nov 22, 2017 · 24 comments

Comments

Projects
None yet
9 participants
@yincongcyincong
Copy link

yincongcyincong commented Nov 22, 2017

i use shell script to go build, but i failed
GOOS=linux GOARCH=386 go build && mv proxyWebApplication proxyWeb/proxyWebApplication && tar zcfv "zip/proxy-linux-386.tar.gz" proxyWeb
why?
this is error information
../github.com/mattn/go-sqlite3/sqlite3_go18.go:26: undefined: SQLiteConn ../github.com/mattn/go-sqlite3/sqlite3_go18.go:27: undefined: namedValue

@yincongcyincong

This comment has been minimized.

Copy link

yincongcyincong commented Nov 22, 2017

my os is linux-amd64, only linux-amd64 can go build

@mattn

This comment has been minimized.

Copy link
Owner

mattn commented Nov 22, 2017

Because you don't install cross C compiler for linux-i386.

@utdrmac

This comment has been minimized.

Copy link

utdrmac commented Nov 24, 2017

Similar issue. Trying to compile for linux/x86_84 on my mac. Code will run on my hosting provider which doesn't have gcc installed. So I need to compile on my mac for use on linux.

$ GOOS=linux GOARCH=amd64 go build --tags "libsqlite3 linux"
# github.com/mattn/go-sqlite3
../github.com/mattn/go-sqlite3/sqlite3_go18.go:18:10: undefined: SQLiteConn
@mattn

This comment has been minimized.

Copy link
Owner

mattn commented Nov 24, 2017

You must install cross C compiler for Linux on your Mac.

@utdrmac

This comment has been minimized.

Copy link

utdrmac commented Nov 24, 2017

Any hints on installing that?

@yincongcyincong

This comment has been minimized.

Copy link

yincongcyincong commented Nov 25, 2017

thanks

@mattn

This comment has been minimized.

Copy link
Owner

mattn commented Nov 25, 2017

@utdrmac I don't have Mac. Sorry.

@Manoj321

This comment has been minimized.

Copy link

Manoj321 commented Nov 27, 2017

@utdrmac Were able to compile linux binary on mac?

@utdrmac

This comment has been minimized.

Copy link

utdrmac commented Nov 27, 2017

Nope. I just booted up a VirtualBox with the same OS as my hosting provider, installed go, etc, compiled, copied. works well. Took about 10m to download/install a CentOS6 VM. Another 10m to install/setup Go. Would have spent a lot longer figuring out cross-compile stuff.

@mingrammer

This comment has been minimized.

Copy link

mingrammer commented Dec 1, 2017

Simillar problem here. I can not cross compile this library for linux/amd64 on macOS now.

@mattn

This comment has been minimized.

Copy link
Owner

mattn commented Dec 1, 2017

Do you use cross C compiler? Maybe you are using host compiler. Check CC in go env.

@mingrammer

This comment has been minimized.

Copy link

mingrammer commented Dec 1, 2017

@mattn Yes I was using the host compiler, it was the cause. So I installed the cross compiler for linux on mac: http://crossgcc.rts-software.org/doku.php?id=compiling_for_linux and ran the build command, the results was successful. (Of course, I did not run this output binary on linux instance yet)

Thank you.

@utdrmac I solved the cross compilation problem on mac with gcc for linux for mac

@yincongcyincong

This comment has been minimized.

Copy link

yincongcyincong commented Dec 4, 2017

@mingrammer do you have gcc for linux for windows

@mingrammer

This comment has been minimized.

Copy link

mingrammer commented Dec 5, 2017

@yincongcyincong I did not find one for windows. You should search it yourself, sorry.

@meeramn

This comment has been minimized.

Copy link

meeramn commented Jan 23, 2018

While building this package for linux on OS X, I'm seeing following error. I tried everything you mentioned on the thread but nothing is working for me. Please let me know your thoughts on this.

(I'm using - GOOS=linux GOARCH=amd64)
../../../github.com/mattn/go-sqlite3/sqlite3_go18.go:18:10: undefined: SQLiteConn

With CGO_ENABLED=1

runtime/cgo
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-gno-record-gcc-switches'
runtime/cgo
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-gno-record-gcc-switches'
clang: warning: argument unused during compilation: '-nopie'
ld: unknown option: --build-id=none
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [dist/tapioca-httpd] Error 2

@mattn

This comment has been minimized.

Copy link
Owner

mattn commented Jan 23, 2018

you need to use cross-C-compiler. you are doing:

compiling C source code for Linux on compiler that can generate Mac binary.

This should be:

compile C source code for Linux on compiler that can generate Linux binary.

So you need to set environment variable CC to the cross-C-compiler.

@meeramn

This comment has been minimized.

Copy link

meeramn commented Jan 23, 2018

I tried as suggested but it is failing on the target linux server with following error.
I used cross compiler provided in http://crossgcc.rts-software.org/doku.php?id=compiling_for_linux

Error on linux server:
/lib64/libc.so.6: version `GLIBC_2.14' not found

Linux server has following installed:
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
glibc-devel-2.12-1.166.el6.7.x86_64

@utdrmac

This comment has been minimized.

Copy link

utdrmac commented Jan 23, 2018

@meeramn you obviously need to update your glibc package on the linux server to 2.14.

@bharath-srinivas

This comment has been minimized.

Copy link

bharath-srinivas commented Jan 29, 2018

For those having this issue on linux (especially if you're using Ubuntu), please do the following:

$ sudo apt-get install gcc-mingw-w64

The above command will install cross compiler for C. Then you can build with the following code:

To build for windows amd64:

GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 go build -o binary_name_amd64.exe .

Similarly for windows 386:

GOOS=windows GOARCH=386 CC=i686-w64-mingw32-gcc CGO_ENABLED=1 go build -o binary_name_386.exe .

Hope this helps.

@bharath-srinivas

This comment has been minimized.

Copy link

bharath-srinivas commented Jan 30, 2018

@mattn Can you suggest me some good cross compiler for mac on linux (Ubuntu 16.04)?. I came across a few that I found out on the internet which I listed below.

Thanks.

@mattn

This comment has been minimized.

Copy link
Owner

mattn commented Jan 30, 2018

@bharath-srinivas sorry, I don't have Mac.

GJRTimmer added a commit to GJRTimmer/go-sqlite3 that referenced this issue May 26, 2018

Update documentation
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 in c9394b1 May 27, 2018

@JonRowe

This comment has been minimized.

Copy link

JonRowe commented Jul 23, 2018

Does anyone have the correct incantation (or value for CC) to use the "cross compiler" on mac? I have gcc installed via brew but can't figure it out so I'm still getting this error, we could then improve the documentation by listing the actual steps required! The url in the page earlier linked is now extinct so it's of no use.

@GJRTimmer

This comment has been minimized.

Copy link
Collaborator

GJRTimmer commented Jul 24, 2018

@utdrmac @mingrammer could you please write an update for the compilation section for MAC within the README. Hope you can take some time for it. I think it will help a lot of people. Don't have Mac myself.

@utdrmac

This comment has been minimized.

Copy link

utdrmac commented Jul 24, 2018

@GJRTimmer Sorry, I gave up on using SQLite3 in my project because this was too complicated to cross-compile for each OS. I switched to https://github.com/coreos/bbolt in my project which is 100% Go and allows me to compile for each os/arch on my mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment