-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Compilation
This package requires CGO_ENABLED=1
ennvironment variable if not set by default, and the presence of the gcc
compiler.
If you need to add additional CFLAGS or LDFLAGS to the build command, and do not want to modify this package. Then this can be achieved by using the CGO_CFLAGS
and CGO_LDFLAGS
environment variables.
For common issues see the Errors section
This package can be compiled for android. Compile with:
go build --tags "android"
For more information see #201
To compile for ARM
use the following environment.
env CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \
CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 \
go build -v
Additional information:
This library can be cross-compiled.
In some cases you are required to the CC
environment variable with the cross compiler.
Additional information:
Building on GCP is not possible because Google Cloud Platform does not allow
gcc` to be executed.
Please work only with compiled final binaries.
To compile this package on Linux you must install the development tools for your linux distribution.
To compile under linux use the build tag linux
.
go build --tags "linux"
If you wish to link directly to libsqlite3 then you can use the libsqlite3
build tag.
go build --tags "libsqlite3 linux"
When building in an alpine
container run the following command before building.
apk add --update gcc musl-dev
sudo yum groupinstall "Development Tools" "Development Libraries"
sudo apt-get install build-essential
OSX should have all the tools present to compile this package, if not install XCode this will add all the developers tools.
Required dependency
brew install sqlite3
For OSX there is an additional package install which is required if you whish to build the icu
extension.
This additional package can be installed with homebrew
.
brew upgrade icu4c
To compile for Mac OSX.
go build --tags "darwin"
If you wish to link directly to libsqlite3 then you can use the libsqlite3
build tag.
go build --tags "libsqlite3 darwin"
Additional information:
To compile this package on Windows OS you must have the gcc
compiler installed.
- Install a Windows
gcc
toolchain. - Add the
bin
folders to the Windows path if the installer did not do this by default. - Open a terminal for the TDM-GCC toolchain, can be found in the Windows Start menu.
- Navigate to your project folder and run the
go build ...
command for this package.
For example the TDM-GCC Toolchain can be found here.
-
Compile error:
can not be used when making a shared object; recompile with -fPIC
When receiving a compile time error referencing recompile with
-FPIC
then you are probably using a hardend system.You can compile the library on a hardend system with the following command.
go build -ldflags '-extldflags=-fno-PIC'
More details see #120
-
Can't build go-sqlite3 on windows 64bit.
Probably, you are using go 1.0, go1.0 has a problem when it comes to compiling/linking on windows 64bit. See: #27
-
go get github.com/mattn/go-sqlite3
throws compilation error.gcc
throws:internal compiler error
Remove the download repository from your disk and try re-install with:
go install github.com/mattn/go-sqlite3