go-duckdb icon indicating copy to clipboard operation
go-duckdb copied to clipboard

`go build` fails on Ubuntu but works on MacOS

Open srirampetavue opened this issue 1 year ago • 5 comments

I have a project where we're using DuckDB using this driver. When I try to build, I get the following error

# github.com/marcboeker/go-duckdb
../../../go/pkg/mod/github.com/marcboeker/[email protected]/transaction.go:6:5: undefined: conn

I noticed that this error only occurs when building from Ubuntu but works fine when building from Mac.

Building for linux Screenshot 2024-09-11 at 6 38 27 PM

Building for mac Screenshot 2024-09-11 at 6 41 42 PM

srirampetavue avatar Sep 11 '24 13:09 srirampetavue

Are you building with CGO_ENABLED=1? go-duckdb uses CGO, if you do not have CGO_ENABLED=1, this error will get returned, although I'm not certain if there are other causes.

TengLun avatar Sep 12 '24 04:09 TengLun

I wasn't using CGO_ENABLED=1. I just tried it and got this error Screenshot 2024-09-12 at 10 24 59 AM

Just for information, this wasn't happening last week when we deployed this in dev. It started happening yesterday only as far as I know. I see that there was a release, but that's v.1.8.0. Is there a chance this change messed something up in the previous versions?

srirampetavue avatar Sep 12 '24 04:09 srirampetavue

It might be that your GCC is building to a newer standard for C. Newer standards for C don't allow implicit function declarations; however in general GCC builds according to older standards that allow implicit function calls with just a warning. Is it possible that your GCC is building to a newer standard (like C99 or C11)? If so, it'll likely error out, rather than just giving you a warning and building anyways.

Try setting GCC to build to an older standard like C90, -std=c90, which will turn the error into the warning and build anyway. Its worth a try, at least.

TengLun avatar Sep 12 '24 05:09 TengLun

Looks like you may need a cross-compiler to build linux binary executable files on MacOS.

Alternatively, you can choose to compile a Linux executable in a docker container (in this case a ubuntu image is recommended because you want the binary file to run on Ubuntu systems), and then you can copy the compiled file to the Linux environment.

apocelipes avatar Sep 12 '24 16:09 apocelipes

This is not only in MacOS. I tried building in a ubuntu 24.04 VM and I got the same issue. But a week ago, in a similar configured VM, I didn't get that issue. Only difference between both VMs are the regions. Everything else is identical

srirampetavue avatar Sep 12 '24 17:09 srirampetavue

Bumping on this issue. Along with @jay-mtl since the release of duckdb 1.8.0. We are also encountering an issue with the debugger with the following error message

2024-09-16T17:33:47+02:00 error layer=dap recovered panic: Encountered an unexpected DWARF CFA opcode: 0x2e
goroutine 34 [running]:
runtime/debug.Stack()
	/home/jc-kaiko/sdk/go1.23.1/src/runtime/debug/stack.go:26 +0x5e
runtime/debug.Stack()
	/home/jc-kaiko/sdk/go1.23.1/src/runtime/debug/stack.go:26 +0x5e
github.com/go-delve/delve/service/dap.(*Session).recoverPanic(0xc0000d4f00, {0xc89e20, 0xc002e2a030})
	/home/jc-kaiko/go/pkg/mod/github.com/go-delve/[email protected]/service/dap/server.go:579 +0x58
panic({0xa84b20?, 0xc0020eb3f0?})
	/home/jc-kaiko/sdk/go1.23.1/src/runtime/panic.go:785 +0x132

Downgrading to 1.7.1 seems to fix the issue. However, is there any significant changes that has been made with this latest release ?

shigedangao avatar Sep 17 '24 12:09 shigedangao

Run this will solve the problem. I had this issue before

sudo apt-get update && sudo apt-get install build-essential

vincenttat22 avatar Sep 17 '24 13:09 vincenttat22

Thanks a lot @vincenttat22 . You're a life saver.

srirampetavue avatar Sep 19 '24 07:09 srirampetavue

@srirampetavue my pleasure, I'm glad it helped.

vincenttat22 avatar Sep 19 '24 11:09 vincenttat22

I'll close this issue as resolved by the above fix.

taniabogatsch avatar Sep 26 '24 08:09 taniabogatsch

Run this will solve the problem. I had this issue before

sudo apt-get update && sudo apt-get install build-essential

Hello I am getting the same error on Windows

E:\duckgo>go build
# github.com/marcboeker/go-duckdb
C:\Users\l6i\go\pkg\mod\github.com\marcboeker\[email protected]\transaction.go:6:5: undefined: conn

Do you know if there's a solution for this?

libe avatar Oct 16 '24 12:10 libe

Unfortunately, I couldn't get it working on Windows either. I reckon you either run your Go App on Linux or WSL2 on Windows.

vincenttatuptio avatar Oct 17 '24 03:10 vincenttatuptio

Did you try following the build steps in the Makefile for our Windows build? Maybe also comparing the GitHub Windows runner configuration can help?

taniabogatsch avatar Oct 17 '24 07:10 taniabogatsch

Run this will solve the problem. I had this issue before

sudo apt-get update && sudo apt-get install build-essential

Hello I am getting the same error on Windows

E:\duckgo>go build
# github.com/marcboeker/go-duckdb
C:\Users\l6i\go\pkg\mod\github.com\marcboeker\[email protected]\transaction.go:6:5: undefined: conn

Do you know if there's a solution for this?

I managed to get it working by installing first gcc:

  • download gcc with https://www.msys2.org/
  • add the path of your MinGW-w64 bin folder
  • set CGO_ENABLED=1
  • go build

libe avatar Oct 17 '24 08:10 libe