Btrieve 2
Loading...
Searching...
No Matches
Using Btrieve with Go

Using Btrieve with Go on Ubuntu 20 x64

Documented below is one approach to configuring the Btrieve 2 SDK for the Go programming language. In this example, we will use the Go Language package to target an Ubuntu 20 x64 environment. It is assumed that Zen is already installed and running.

  • Install SWIG and Go if not already installed.
    • Open a terminal window as a non-"root" user.
    • sudo apt install swig
    • sudo apt install golang
  • Install the Btrieve 2 Linux SDK for Zen.
  • Generate, build, and install Btrieve Go.
    • Open a terminal window as a non-"root" user.
    • Change directory into the Btrieve 2 SDK directory.
    • Copy Btrieve Go into the GOPATH source directory.
      • cp -r swig/btrieveGo/ ~/go/src
        • Ensure that the GOPATH source directory already exists.
        • Note that the path to the GOPATH source directory used above may differ.
    • Build and install Btrieve Go.
      • export CGO_CPPFLAGS="-I$(pwd)/include/"
      • export CGO_LDFLAGS="-shared -L/usr/local/actianzen/lib64 -lbtrieveCpp"
      • go install btrieveGo
    • Build and execute the Btrieve Go sample program.
      • export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/usr/local/actianzen/lib64
      • go build samples/btest.go
      • ./btest 9
        • You should see the output "record: (9, 81, 3.000000)".
        • You may need to change the permissions of the current directory if you receive the error "Error: BtrieveClient.FileCreate():94:Permission error".