I've been trying to connect to an Oracle DB from Go but since my knowledge of C and corresponding toolchains is very very basic I ran into some problems. I am using the following repo: https://github.com/mattn/go-oci8
After I had some problems with pkg-config (exit status 3221225595) I configured the linking directly:
#cgo LDFLAGS: -L C:/oracle/ora112/oci/lib/msvc -loci
#cgo CFLAGS: -I C:/oracle/ora112/oci/include
Instead of
#cgo pkg-config: oci8
This seems to work, but now I get compilation errors:
In file included from C:/oracle/ora112/oci/include/oci.h:537:0,
from repositories\Go\src\github.com\mattn\go-oci8\oci8.go:9:
C:/oracle/ora112/oci/include/oratypes.h:236:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ubig_ora'
typedef unsigned _int64 ubig_ora;
^
After some research I believe that the problem is "unsigned _int64", which should be uint64_t - at least using this does not result in an error. Thus, I tried to include typedefs for ubig_ora and sbig_ora in the .go-file:
#include <inttypes.h>
typedef uint64_t ubig_ora;
typedef int64_t sbig_ora;
Unfortunately this does not really help, I get the same error message as before, just the aftereffects disappeared.
I suspect that I need to configure the cgo-call in some way, that gcc accepts the standard C-types and does not require the "new" C99 types (I kind of struggle with the correct terminology because the whole C environment is very new to me). I use MinGW64 as compiler, retrieved from http://nuwen.net/mingw.html.
MinGW information:
λ gcc --version
gcc (GCC) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
λ gcc -dumpmachine
x86_64-w64-mingw32
It would help me a lot, if you could point out some things I could try to get this to work. Unfortunately my C knowledge is not really existent so I have some problems continuing.
Thank you very much in advance Florian