1

I develop a utility in Go that requires recent version of sqlite. I'm interested only in targeting specific architecture, to be specific: x64 linux. I'm developing that utility on Mac OS X. I'm using go-sqlite3 driver. I use GNU Make + Glide to build my utility. In order to cross compile on my Mac I pass specific arch flags to make.

Repos on Linux platforms that I'm targeting usually have quite old versions of sqlite that don't have features that I need in my utility.

I can manually compile and install required version of sqlite on all the platforms that I need, but it is quite cumbersome. I wonder if there is a good way to either statically link a specific version of sqlite or somehow bundle a utility with specific version of sqlite dynamic library.

Even though I mention sqlite a lot, this question can be generalized to other libraries: how to bundle a golang app with a specific version of C library an outdated version of which may be installed on the target platform.

Also: how to better organize development of that utility so that other devs won't need to manually compile and install specific version of the library - the preference is to use Makefile that would build all the binaries for required target platform. I see that I can just copy code of specific version of library (e.g. sqlite) to my utility's repo though I wonder if there is a better option - maybe I can somehow use glide dependencies for that purpose and build library that I need as part of my other dependencies.

Al Star
  • 13
  • 3
  • 2
    You might want to start looking into using containers. That way you determine the full installation and avoid these conflicts. – Norbert Feb 17 '18 at 19:40
  • That's a good point, I'm doing this for services, but in this case using docker container is not desirable - this is a wide purpose utility that might be run on "old fashioned" non-containerized environments. Though this is a good illustration how use of containers can simplify development and deployment. – Al Star Feb 17 '18 at 20:49
  • Then you have two possible other solutions to prevent issues: 1) Document which lib to use and only guarantee that lib, or 2) compile on the users system (Not a 100% guarantee with go with the way they use C bindings, but should catch most situations) – Norbert Feb 17 '18 at 23:28
  • That's a good point. 1 might be actually easier to provide for libs like sqlplus which provide version API. Checking against specific version should suffice. – Al Star Feb 18 '18 at 00:05
  • Option 3: Compile it using docker by bind-mounting your source directory into the container [as described in Go's official docker repo description](https://hub.docker.com/_/golang/) – Markus W Mahlberg Feb 18 '18 at 12:35

0 Answers0