Using cgo to connect to Oracle DB with OCI disabled using signed / unsigned _int64 type
I tried to connect to Oracle database from Go, but since my knowledge of C and related toolchains is very simple, I ran into some problems. I am using the following repo: https://github.com/mattn/go-oci8
After having problems with pkg-config (exit status 3221225595), I configured the link directly:
#cgo LDFLAGS: -L C:/oracle/ora112/oci/lib/msvc -loci
#cgo CFLAGS: -I C:/oracle/ora112/oci/include
Instead
#cgo pkg-config: oci8
This seems to work, but now I am getting 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 "unsigned _int64" issue, which should be uint64_t - at least using this, does not result in an error. Thus, I tried to include the 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 it doesn't help much, I get the same error message as before, only the aftereffects are gone.
I suspect that I need to configure cgo-call somehow, that gcc accepts standard C types and does not require "new" C99 types (I'm kind of struggling with the correct terminology because the whole C environment is very new to me). I am using MinGW64 as the compiler extracted 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 that I could try to get this to work. Unfortunately my knowledge of C doesn't really exist, so I have some problems.
Thank you very much in advance Florian
source to share
No one has answered this question yet
Check out similar questions: