ora
ora copied to clipboard
Unable to install go- Rana Ora V3 on windows 64 bits
Hello,
i m trying to install the package go-oci8 and always get the following message: become crazy. When I checked the directory created there is only: /rana/ora.v3
- date.a
- num.a
thx for your help.
ericg
error: c:\go\work\pkg>go get gopkg.in/rana/ora.v3
pkg-config --cflags oci8
pkg-config: exit status 3221225595
--- oci8.pc prefix=/devel/target/XXXXXXXXXXXXXXXXXXXXXXXXXX exec_prefix=${prefix} libdir=C:/instantclient_12_1/sdk/lib/msvc includedir=C:/instantclient_12_1/sdk/include glib_genmarshal=glib-genmarshal gobject_query=gobject-query glib_mkenums=glib-mkenums Name: oci8 Description: oci8 library Libs: -L${libdir} -loci Cflags: -I${includedir} Version: 12.1
my configuration:
windows 10, Oracle client 64 b, GO 64 in PATH i have : C:\GO\BIN;C:\go\pkg-config-0.26\bin;C:\go\pkg-config-0.26\PKG_CONFIG_PATH;C:\go\TDM-GCC-64\bin
PKG_CONFIG_PATH=C:\go\pkg-config-0.26\PKG_CONFIG_PATH
go get -u gopkg.in/rana/ora.v4
Copy the right oci8.pc under %PKG_CONFIG_PATH%
:
cp %GOPATH%\src\gopkg.in\rana\ora.oci8_windows_amd64.pc %PKG_CONFIG_PATH%\oci8.pc
Customize oci8.pc
till
pkg-config --libs --cflags oci8
Shows the right directories for your installation of Oracle InstantClient libraries and include files. Then
go install gopkg.in/rana/ora.v4
Thanks for information. But I m still struggling for this install. I Think the biggest problem is the pkg-config.exe . I don't know how to get a correct version of this pgm for windows 64 bits.
thanks for help
eric g
sorry , but I get some issues when compiled. (environement Widows 10 64 Bits, Instantclient 64 bits and GO 64 bits) Thx for your help,
ericg c:\Go\pkg-config>go get gopkg.in/rana/ora.v4
gopkg.in/rana/ora.v4
c:/instantclient_12_1/sdk/lib/msvc/oci.lib: error adding symbols: File in wrong format collect2.exe: error: ld returned 1 exit status
here my config c:\Go\pkg-config>go env set GOARCH=amd64 set GOBIN=c:\go\bin set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\go\work set GORACE= set GOROOT=C:\Go set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set CC=gcc set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\eric\AppData\Local\Temp\go-build919654683=/tmp/go-build -gno-record-gcc-switches set CXX=g++ set CGO_ENABLED=1 set PKG_CONFIG=pkg-config set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2
@ericgarcia38 looks to be the same issue I had trying to install oci8. Are you using TDM_GCC? The problem for me was that TDM_GCC has a compiler / linker bug that prevents from compiling certain files. I used ming64 instead and it worked. You can see my detailed posts regarding that here:
Thanks a lot, @oqamar ! I do have Windows, but no dev env on it... So suggestions like this helps a lot!
I'm posting this in case anyone else ends up here when google searching, including myself in the future.
How to install Oracle Database 64bit Drivers on Windows 64bit with Golang 64bit:
Download "Oracle Instant Client" 64bit from: http://www.oracle.com/technetwork/topics/winx64soft-089540.html You will need to download the 'basic' and 'sdk' packages, and unzip them to the same directory. Add the directory to your path.
Download and Install MSYS2 64bit from: http://www.msys2.org/
Run the MSYS2 MINGW64 terminal and do the following:
# Update pacman
pacman -Su
# Close terminal and open a new terminal
# Update all other packages
pacman -Su
# Install pkg-config and gcc
pacman -S mingw64/mingw-w64-x86_64-pkg-config mingw64/mingw-w64-x86_64-gcc
Under the /path/to/msys64/mingw64/share/pkgconfig/
Create a file exactly called oci8.pc
and put in it (or copy the one from this library's contrib):
prefix=C:/path/to/instantclient_12_1/sdk
version=12.1
build=client64
libdir=${prefix}/lib
includedir=${prefix}/include
glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums
Name: oci8
Description: Oracle database engine
Version: ${version}
Libs: -L${libdir} -loci
Libs.private:
Cflags: -I${includedir}
Open the MSYS2 MINGW64 terminal, and do the following:
# Set ENV VARS:
export ORACLE_HOME=/c/path/to/instantclient_12_1
export LD_LIBRARY_PATH=${ORACLE_HOME}
export PKG_CONFIG_PATH=${ORACLE_HOME}:/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
# Set CGO flags
export CGO_CFLAGS="-IC:\path\to\instantclient_12_1\sdk\include"
export CGO_LDFLAGS="-LC:\path\to\instantclient_12_1 -loci"
# You may need to add golang to your PATH, since MSYS overwrites you path.
# I did this by having MSYS inherit my PATH, but this can be done in any way you like.
# Go get golang oracle drivers
go get -u -v github.com/mattn/go-oci8
go get -u -v gopkg.in/rana/ora.v4
That worked for me, without having to resort to downgrading to Golang 32bit and doing everything in 32bit (if you are on 32bit Windows, see here: https://andrey.nering.com.br/2016/connecting-golang-to-oracle-database/).
@veqryn but doesn't this then mean that my GO projects have to be within the universe of msys64 and/or my GO distribution ? I'm using JetBrains Gogland IDE where I specify my GoPath , I am using TDM-GCC which is on the Win path for GCC compilation and actually using a special branch of 1.8.3 so that I could effectively do buildmode=c-shared on Win64, I mention only because , I don't want to reconfigure everything that I'm doing so that my Go projects live under the msys64 universe. Am I missing something? If I do the above can I extract from msys64 , any artifact that I can then copy under my current project ? thanks
After I install the oracle drivers with the above, I'm able to compile and run from inside Gogland without any tweaking of Gogland (you still need those env vars set though).
@veqryn thanks, good to know, so what I"m doing is actually compiling an executable using GO's CGO , I'll assume that said executable i.e. once generated is portable i.e. the need for env vars are just during compile time, sounds obvious but I'm still new to GO and really haven't done much C.
Also this seems foreign to me:
PKG_CONFIG_PATH=${ORACLE_HOME}:/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig i.e. the colon after ORACLE_HOME I.E. /mingw64/lib/pkgconfig:/mingw64/share/pkgconfig would not exist under ORACLE_HOME
and one final thing , in my Gogland project I set my GoPath to the root of my project, but you are doing Go gets from within the mingw64 terminal so I assume that those packages will be installed where Windows has set the GOPath, not sure of the impact of that
anyhow will try what you have generously provided , thanks
PKG_CONFIG_PATH is a env var for a path list: a list of paths separated by colons. The pkg-config program will walk through them and stops at the first match (where it finds oci8.pc). (Just like PATH works).
GOPATH is a path for Go related sources ($GOPATH/src) and compiled packages ($GOPATH/pkg). This can be a path list, too!
k, thanks, as @veqryn noted, msys64 does within the context of its terminal wipe out the path not only to GO but to GIT, I tried this morning setting the path from within the msys64 shell to the pre-existing paths within my Windows instance but that was not taking, maybe something silly
msys has a setting somewhere to add the windows path when you start a shell. Also, you should probably keep your gopath the same inside and outside of your ide / gogland, for your own sanity. Lastly, i am pretty sure that you still need the oracle libraries after you've compiled, because oracle doesn't allow static compilation. Not sure if you need the env vars after tho, but it would be easy to test.
i have debated that, but there comes scenarios when its beneficial not to , for example, I can only do CGO buildmode=c-archive on Win64 using a particular developer's branch, a case where my GORoot and Path are different than for other projects, also coming from Ruby where I often have had different projects running on different versions and thus different gem sets and within IDEA I just got used to siloing projects that way
regarding the msys setting thanks for that will look
yes, certainly true that one needs the oracle dlls to connect to Oracle and some of the env vars, was referring more to the other env vars which I now am fairly certain that they are just about compiling the GO oracle driver thanks
@veqryn @tgulacsi btw, this seems useful: https://sourceforge.net/p/msys2/discussion/general/thread/dbe17030/
@veqryn followed your instructions and got to the gets of the drivers , failed upon attempting the first driver i.e.:
C:\Users\amira\go\src\github.com\mattn\go-oci8\oci8.go:4:10: fatal error: oci.h: No such file or directory #include <oci.h> ^~~~~~~ compilation terminated.
I can't find oci.h in my instant_client distribution , so I guess I failed to download a package from oracle i.e. I had downloaded the SDK
@veqryn , @tgulacsi I downloaded 11.2 must have had an old SDK, but I now get these errors, I suppose I should try to use the oracle 12.x client, but we are running 11 databases,
error: In file included from C:\instantclient_11_2\sdk\include/oci.h:541:0, from C:\Users\amira\go\src\github.com\mattn\go-oci8\oci8.go:4: C:\instantclient_11_2\sdk\include/oratypes.h:236:25: error: expected '=', ',', ';', 'asm' or 'attribut' before 'ubig_ora' typedef unsigned _int64 ubig_ora; ^~~~~~~~ C:\instantclient_11_2\sdk\include/oratypes.h:237:25: error: expected '=', ',', ';', 'asm' or 'attribut' before 'sbig_ora' typedef signed _int64 sbig_ora; ^~~~~~~~ In file included from C:\instantclient_11_2\sdk\include/oci.h:3045:0, from C:\Users\amira\go\src\github.com\mattn\go-oci8\oci8.go:4: C:\instantclient_11_2\sdk\include/ociap.h:7459:40: error: unknown type name 'ubig_ora' OraText *path, ubig_ora *lenp ); ^~~~~~~~ C:\instantclient_11_2\sdk\include/ociap.h:7471:36: error: unknown type name 'ubig_ora' uword origin, ubig_ora offset, sb1 dir ); ^~~~~~~~ C:\instantclient_11_2\sdk\include/ociap.h:8278:23: error: unknown type name 'sbig_ora' sbig_ora bufferLength, sbig_ora *returnLength, ^~~~~~~~ C:\instantclient_11_2\sdk\include/ociap.h:8278:46: error: unknown type name 'sbig_ora' sbig_ora bufferLength, sbig_ora *returnLength, ^~~~~~~~
12.1 client can talk to 11.2 databases (or older) flawlessly!
amiracam [email protected] ezt írta (időpont: 2017. szept. 13., Sze, 20:58):
@veqryn https://github.com/veqryn , @tgulacsi https://github.com/tgulacsi I downloaded 11.2 must have had an old SDK, but I now get these errors, I suppose I should try to use the oracle 12.x client, but we are running 11 databases,
error: In file included from C:\instantclient_11_2\sdk\include/oci.h:541:0, from C:\Users\amira\go\src\github.com\mattn\go-oci8\oci8.go:4: C:\instantclient_11_2\sdk\include/oratypes.h:236:25: error: expected '=', ',', ';', 'asm' or 'attribut' before 'ubig_ora' typedef unsigned _int64 ubig_ora; ^~~~~~~~ C:\instantclient_11_2\sdk\include/oratypes.h:237:25: error: expected '=', ',', ';', 'asm' or 'attribut' before 'sbig_ora' typedef signed _int64 sbig_ora; ^~~~~~~~ In file included from C:\instantclient_11_2\sdk\include/oci.h:3045:0, from C:\Users\amira\go\src\github.com\mattn\go-oci8\oci8.go:4: C:\instantclient_11_2\sdk\include/ociap.h:7459:40: error: unknown type name 'ubig_ora' OraText *path, ubig_ora *lenp ); ^~~~~~~~ C:\instantclient_11_2\sdk\include/ociap.h:7471:36: error: unknown type name 'ubig_ora' uword origin, ubig_ora offset, sb1 dir ); ^~~~~~~~ C:\instantclient_11_2\sdk\include/ociap.h:8278:23: error: unknown type name 'sbig_ora' sbig_ora bufferLength, sbig_ora *returnLength, ^~~~~~~~ C:\instantclient_11_2\sdk\include/ociap.h:8278:46: error: unknown type name 'sbig_ora' sbig_ora bufferLength, sbig_ora *returnLength, ^~~~~~~~
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rana/ora/issues/155#issuecomment-329264395, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPoSodlntkvBT4KFhim8f9j17hW0lqkks5siCXlgaJpZM4ME1w0 .
ok, thanks, I'll switch to that and see if I get any further, also trying this 👍 https://gist.github.com/X3STeNLiTE/8f60a1c431fb0623af59b2a1c6248786
@veqryn , @tgulacsi I was successful using the 12_2 oracle instant client library, i.e. the Go oracle drivers "get" without issue, I'll have to try actual access to oracle db from work i.e. haven't found a way of setting up a "play" oracle db, guess I haven't tried, thanks
Until recently that was an issue. But now, Oracle has development/testing docker containers for Oracle DB available, which you can download here with an account: https://container-registry.oracle.com
Also, you should post whatever you did to solve your issues, if they are not already covered in my or tgulacsi's directions above.