go-duckdb
go-duckdb copied to clipboard
`go build` fails on Ubuntu but works on MacOS
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
Building for mac
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.
I wasn't using CGO_ENABLED=1. I just tried it and got this error
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?
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.
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.
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
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 ?
Run this will solve the problem. I had this issue before
sudo apt-get update && sudo apt-get install build-essential
Thanks a lot @vincenttat22 . You're a life saver.
@srirampetavue my pleasure, I'm glad it helped.
I'll close this issue as resolved by the above fix.
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?
Unfortunately, I couldn't get it working on Windows either. I reckon you either run your Go App on Linux or WSL2 on Windows.
Did you try following the build steps in the Makefile for our Windows build? Maybe also comparing the GitHub Windows runner configuration can help?
Run this will solve the problem. I had this issue before
sudo apt-get update && sudo apt-get install build-essentialHello 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: connDo 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