Compilation golang binding on Windows 10

According to foundationdb.org I installed Client and Serger of FoundationDB: (foundationdb-6.2.7-x64.msi)

Now I want to use the foundationdb server in my GO module.
It gets last version.

go build
gives me

C:\Users.…\go\pkg\mod\github.com\apple\foundationdb\bindings\go@v0.0.0-20191027010432-529b35a88625\src\fdb\cluster.go:26:11: fatal error: foundationdb/fdb_c.h: No such file or directory
// #include <foundationdb/fdb_c.h>
^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

What exactly should I make yet on my Windows to be able to build my project?
Thank you in advance.

If I’ve made sense of the windows installer code correctly, it’s that the installer drops fdb_c.h into ProgramFiles/foundationdb/include/foundationdb/fdb_c.h , which probably isn’t on the default search path for MSVC. You’d need to either add foundationdb/fdb_c.h to MSVC’s default include directories, or configure go build to add the directory as an include path.

If you wouldn’t mind filing an issue with reproduction instructions, I’d appreciate it, as you probably won’t be the last person to run into this issue.

Alex, I use Visual Studio code as IDE for GO development.
Do you know where should I set “MSVC’s default include directories” exactly?
or how “configure go build to add the directory as an include path”
?

I don’t particularly have a windows box on hand with a go development environment set up, so I can’t actually offer concrete instructions. I would imagine that somewhere on google you’d be able to learn about “msvc default include path” or “go build c include path” ?

Hey there,

I was recently messing around with doing some development on windows with go as well. This is just about pointing to the correct header files. I had to make a change on my system to the cluster.go file:

// FoundationDB Go API

package fdb

// #cgo CFLAGS: -I"C:/Program Files/foundationdb/include"
// #cgo LDFLAGS: -L"C:/Program Files/foundationdb/bin" -lfdb_c
// #define FDB_API_VERSION 620
// #include <foundationdb/fdb_c.h>
import "C"

However, I ran into a separate issue, which is I don’t think the windows DLLs / Client are compiled with TLS:

> fdbcli.exe --tls_certificate_file=fdb.pem --tls_ca_file=ca.crt --log
FoundationDB CLI 6.2 (v6.2.7)
usage: C:\Program Files\foundationdb\bin\fdbcli.exe [OPTIONS]

  -C CONNFILE    The path of a file containing the connection string for the
                 FoundationDB cluster. The default is first the value of the
                 FDB_CLUSTER_FILE environment variable, then `./fdb.cluster',
                 then `C:\ProgramData\foundationdb\fdb.cluster'.
  --log          Enables trace file logging for the CLI session.
  --log-dir PATH Specifes the output directory for trace files. If
                 unspecified, defaults to the current directory. Has
                 no effect unless --log is specified.
  --trace_format FORMAT
                 Select the format of the log files. xml (the default) and json
                 are supported. Has no effect unless --log is specified.
  --exec CMDS    Immediately executes the semicolon separated CLI commands
                 and then exits.
  --no-status    Disables the initial status check done when starting
                 the CLI.
  -v, --version  Print FoundationDB CLI version information and exit.
  -h, --help     Display this help and exit.

It requires some additional local setup. If CMake sees that you don’t have a TLS library available, it will disable TLS. The instructions to set up TLS support are in the second half of the windows build instructions.

I didn’t build / compile the client library, I downloaded it

Well, that’s embarressing then. I don’t see an issue that exists for this, so I’ve filed one.