Mac 下 golang oracle 的安装

golang oracle 安装

下载 instantclient

下载链接

www.oracle.com/database/technologi...

liunx下载链接

www.oracle.com/database/technologi...

下载版本

instantclient-sdk-macos.x64-12.2.0.1.0-2.zip
instantclient-basic-macos.x64-12.2.0.1.0-2.zip

解压合并

把 sdk 放在 basic 中

拷贝,链接

这一步的时候不急着软链,先运行go代码,根据报错提示做软链到 /usr/local/lib

安装 pkg-config,默认是系统安装的,如果自带没安装自己安装下

brew install pkg-config

新建oci8.pc

luwei@luweideMacBook-Pro-2 instantclient_12_2 % pwd
/Users/myself/Golang/nagatyase/instantclient_12_2
luwei@luweideMacBook-Pro-2 instantclient_12_2 % 
luwei@luweideMacBook-Pro-2 instantclient_12_2 % cat oci8.pc 
prefixdir=/Users/myself/Golang/nagatyase/instantclient_12_2   // 你的路径
libdir=${prefixdir} 
includedir=${prefixdir}/sdk/include
Name: OCI
Description: Oracle database driver
Version: 12.2  // 你的版本
Libs: -L${libdir} -lclntsh
Cflags: -I${includedir}
luwei@luweideMacBook-Pro-2 instantclient_12_2 % 

查看

luwei@luweideMacBook-Pro-2 go-simple-task % pkg-config --cflags oci8
-I/Users/myself/Golang/nagatyase/instantclient_12_2/sdk/include

添加环境变量

luwei@luweideMacBook-Pro-2 lnmp % vim ~/.bash_profile

vim 中加入内容
//注意这个地方写的 oci8.pc的地址,文件在哪写到哪
export PKG_CONFIG_PATH=/Users/myself/Golang/nagatyase/instantclient_12_2
export LD_LIBRARY_PATH=/Users/myself/Golang/nagatyase/instantclient_12_2

luwei@luweideMacBook-Pro-2 lnmp % source ~/.bash_profile

安装

如果执行失败,那么就换一个终端页面,因为之前的会不生效

go get github.com/mattn/go-oci8

执行报错

Mac 下 golang oracle 的安装

解决办法

Mac 下 golang oracle 的安装

本作品采用《CC 协议》,转载必须注明作者和本文链接
good good study day day up
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!