chdb-io / chdb-go

Go bindings and cli for chDB, an in-process SQL OLAP Engine powered by ClickHouse
https://chdb.io
Apache License 2.0
84 stars 3 forks source link

Compiling a statically linked binary #8

Open loicalleyne opened 6 months ago

loicalleyne commented 6 months ago

Is it possible to have an option to compile a statically linked Go binary so there's no dependency on having libchdb.so present on the machine it's running on? My understanding is you need to build a static library libchdb.a file instead of a dynamic library libchdb.so, I tried modifying the chdb build script to see if it was possible and ran into a linker issue which I couldn't get past.

auxten commented 5 months ago

It's not that simple. libchdb contains so many libs like llvm, jemalloc. There need some special linkage tricks to make it work well with symbols from golang.

Still, it's possible to make a libchdb.a. Just need some efforts.

aybabtme commented 3 days ago

👋 coming here for this as well. I'm currently using duckdb whereas I'd prefer to use chdb. I'm not super well versed into linking C libs, but the Go duckdb bindings use modvendor and default to static linking.

auxten commented 3 days ago

@aybabtme Thank you for the insight. The most challenging part is make the libchdb.a work. Please also follow up on this issue https://github.com/chdb-io/chdb/issues/101