交叉编译时如何使用Oracle Instant Client SDK?

通常,在Windows for Mac上交叉编译go程序很容易; 但是,当程序连接到数据库(例如,使用mattn / go-oci8的Oracle)时,交叉编译将失败,例如:</ p>

 ➜tmp GOOS = windows go build。

#github.com/mattn/go-oci8
../github.com/mattn/go-oci8/oci8_go18.go:13:10:undefined:OCI8Conn
</ code> </ pre>

我已经搜索了很多东西,基本上我需要为目标平台设置</ p>

(1)编译器,并为目标安装
(2)安装oracle Instant Client sdk 平台。 </ p>

但要弄清楚该怎么做确实不容易。 交叉编译go程序的最佳实践是什么? 可以同时在Mac上安装两个版本的oracle sdk(win / mac)吗?</ p>

ps。 我的oci8.pc是这样的:</ p>

  prefixdir = / Users / nicklee / OracleDriver / instantclient_12_2 / 
libdir = $ {prefixdir}
includedir = $ {prefixdir} / sdk / include
includedir = $ {prefixdir} / sdk_windows64 / include

名称:OCI
描述:Oracle数据库驱动程序
版本:12.2
Libs:-L $ {libdir} -lclntsh
Cflags:-I $ {includedir}
</ code> </ pre>
</ div>

展开原文

原文

Usually, it is easy to cross-compile go program on Mac for Windows; however, when the program connect to database (for example, Oracle, using mattn/go-oci8), cross compile will fail like:

➜  tmp GOOS=windows go build .
# github.com/mattn/go-oci8
../github.com/mattn/go-oci8/oci8_go18.go:13:10: undefined: OCI8Conn

I've googled a lot, basically I need to set

(1) compiler for the target platform, and (2) install oracle instant client sdk for target platform.

But it is really not easy to figure out how to do. What is the best practice to cross compile go program? Can two versions oracle sdk (win/mac) be installed on Mac at the same time?

ps. My oci8.pc is like this:

prefixdir=/Users/nicklee/OracleDriver/instantclient_12_2/
libdir=${prefixdir}
includedir=${prefixdir}/sdk/include
includedir=${prefixdir}/sdk_windows64/include

Name: OCI
Description: Oracle database driver
Version: 12.2
Libs: -L${libdir} -lclntsh
Cflags: -I${includedir}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐