|
| 1 | +# Installing go_ibm_db |
| 2 | + |
| 3 | +*Copyright (c) 2014 IBM Corporation and/or its affiliates. All rights reserved.* |
| 4 | + |
| 5 | +Permission is hereby granted, free of charge, to any person obtaining a copy of this |
| 6 | +software and associated documentation files (the "Software"), to deal in the Software |
| 7 | +without restriction, including without limitation the rights to use, copy, modify, |
| 8 | +merge, publish, distribute, sublicense, and/or sell copies of the Software, |
| 9 | +and to permit persons to whom the Software is furnished to do so, subject to the |
| 10 | +following conditions: |
| 11 | + |
| 12 | +The above copyright notice and this permission notice shall be included in all copies |
| 13 | +or substantial portions of the Software. |
| 14 | + |
| 15 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
| 16 | +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
| 17 | +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE |
| 18 | +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 19 | +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | +DEALINGS IN THE SOFTWARE. |
| 21 | + |
| 22 | +## Contents |
| 23 | + |
| 24 | +1. [Overview](#Installation) |
| 25 | +2. [ibm_db Installation on Linux](#inslnx) |
| 26 | +3. [ibm_db Installation on MacOS](#insmac) |
| 27 | +4. [ibm_db Installation on Windows](#inswin) |
| 28 | + |
| 29 | +## <a name="overview"></a> 1. Overview |
| 30 | + |
| 31 | +The [*go_ibm_db*](https://github.com/ibmdb/go_ibm_db) is an asynchronous/synchronous interface for GoLang to IBM DB2. |
| 32 | + |
| 33 | +Following are the steps to installation in your system. |
| 34 | + |
| 35 | +This go_ibm_db driver has been tested on 64-bit/32-bit IBM Linux, MacOS and Windows. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +## <a name="inslnx"></a> 2. Go_ibm_db Installation on Linux. |
| 42 | + |
| 43 | +### 2.1 Install GoLang for Linux |
| 44 | + |
| 45 | +Download the |
| 46 | +[GoLang Linux binaries](https://golang.org/dl) or [Go Latest binaries](https://go.dev/dl) and |
| 47 | +extract the file, for example into `/mygo`: |
| 48 | + |
| 49 | +``` |
| 50 | +cd /mygo |
| 51 | +wget -c https://golang.org/dl/go1.20.5.linux-amd64.tar.gz |
| 52 | +tar -xzf go1.20.5.linux-amd64.tar.gz |
| 53 | +``` |
| 54 | + |
| 55 | +Set PATH to include Go: |
| 56 | + |
| 57 | +``` |
| 58 | +export PATH=/mygo/go/bin:$PATH |
| 59 | +``` |
| 60 | + |
| 61 | +### 2.2 Install go_ibm_db |
| 62 | + |
| 63 | +Following are the steps to install [*go_ibm_db*](https://github.com/ibmdb/go_ibm_db) from github. |
| 64 | +using directory `/goapp` for example. |
| 65 | + |
| 66 | +#### 2.2.1 Direct Installation. |
| 67 | +``` |
| 68 | +1. mkdir goapp |
| 69 | +2. cd goapp |
| 70 | +3. go install github.com/ibmdb/go_ibm_db/installer@latest |
| 71 | + or |
| 72 | + go install github.com/ibmdb/go_ibm_db/[email protected] |
| 73 | +``` |
| 74 | + |
| 75 | +It's Done. |
| 76 | + |
| 77 | +#### 2.2.2 Manual Installation by using git clone. |
| 78 | + |
| 79 | +``` |
| 80 | +1. mkdir goapp |
| 81 | +2. cd goapp |
| 82 | +3. git clone https://github.com/ibmdb/go_ibm_db/ |
| 83 | +``` |
| 84 | + |
| 85 | +### 2.3 Download clidriver |
| 86 | + |
| 87 | +Download clidriver in your system, use below command: |
| 88 | +go to installer folder where go_ibm_db is downloaded in your system |
| 89 | +(Example: /home/uname/go/src/github.com/ibmdb/go_ibm_db/installer or /home/uname/goapp/go_ibm_db/installer |
| 90 | +where uname is the username) and run setup.go file (go run setup.go) |
| 91 | + |
| 92 | + |
| 93 | +### 2.4 Set environment variables to clidriver directory path |
| 94 | + |
| 95 | +#### 2.4.1 Manual |
| 96 | +``` |
| 97 | +export IBM_DB_HOME=/home/uname/clidriver |
| 98 | +export CGO_CFLAGS=-I$IBM_DB_HOME/include |
| 99 | +export CGO_LDFLAGS=-L$IBM_DB_HOME/lib |
| 100 | +export LD_LIBRARY_PATH=/home/uname/clidriver/lib |
| 101 | +or |
| 102 | +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IBM_DB_HOME/lib |
| 103 | +``` |
| 104 | + |
| 105 | +#### 2.4.2 Script file |
| 106 | +``` |
| 107 | +cd .../go_ibm_db/installer |
| 108 | +source setenv.sh |
| 109 | +``` |
| 110 | +## <a name="insmac"></a> 3. Go_ibm_db Installation on MacOS. |
| 111 | + |
| 112 | +### 3.1 Install GoLang for Mac |
| 113 | + |
| 114 | +Download the |
| 115 | +[GoLang MacOS binaries](https://golang.org/dl) or [GoLang Latest binaries](https://go.dev/dl) and |
| 116 | +extract the file. |
| 117 | + |
| 118 | +### 3.2 Install go_ibm_db |
| 119 | + |
| 120 | +#### 3.2.1 Direct Installation. |
| 121 | +``` |
| 122 | +1. mkdir goapp |
| 123 | +2. cd goapp |
| 124 | +3. go install github.com/ibmdb/go_ibm_db/installer@latest |
| 125 | + or |
| 126 | + go install github.com/ibmdb/go_ibm_db/[email protected] |
| 127 | +``` |
| 128 | + |
| 129 | +It's Done. |
| 130 | + |
| 131 | +#### 3.2.2 Manual Installation by using git clone. |
| 132 | +``` |
| 133 | +1. mkdir goapp |
| 134 | +2. cd goapp |
| 135 | +3. git clone https://github.com/ibmdb/go_ibm_db/ |
| 136 | +``` |
| 137 | + |
| 138 | +### 3.3 Download clidriver |
| 139 | + |
| 140 | +Download clidriver in your system, use below command: |
| 141 | +go to installer folder where go_ibm_db is downloaded in your system |
| 142 | +(Example: /home/uname/go/src/github.com/ibmdb/go_ibm_db/installer or /home/uname/goapp/go_ibm_db/installer |
| 143 | +where uname is the username) and run setup.go file (go run setup.go) |
| 144 | + |
| 145 | + |
| 146 | +### 3.4 Set environment variables to clidriver directory path |
| 147 | + |
| 148 | +#### 3.4.1 Manual |
| 149 | +``` |
| 150 | +export IBM_DB_HOME=/home/uname/clidriver |
| 151 | +export CGO_CFLAGS=-I$IBM_DB_HOME/include |
| 152 | +export CGO_LDFLAGS=-L$IBM_DB_HOME/lib |
| 153 | +
|
| 154 | +export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/home/uname/go/src/github.com/ibmdb/clidriver/lib |
| 155 | +or |
| 156 | +export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$IBM_DB_HOME/lib |
| 157 | +``` |
| 158 | + |
| 159 | +#### 3.4.2 Script file |
| 160 | +``` |
| 161 | +cd .../go_ibm_db/installer |
| 162 | +source setenv.sh |
| 163 | +``` |
| 164 | + |
| 165 | +## <a name="inswin"></a> 4. Go_ibm_db Installation on Windows. |
| 166 | + |
| 167 | +### 4.1 Install GoLang for Windows |
| 168 | + |
| 169 | +Download the [Go Windows binary/installer](https://golang.org/dl) or [Go Latest binaries](https://go.dev/dl/) and |
| 170 | +install it. |
| 171 | + |
| 172 | +### 4.2 Install go_ibm_db |
| 173 | + |
| 174 | +Following are the steps to install [*go_ibm_db*](https://github.com/ibmdb/go_ibm_db) from github. |
| 175 | +using directory `/goapp` for example. |
| 176 | + |
| 177 | +#### 4.2.1 Direct Installation. |
| 178 | +``` |
| 179 | +1. mkdir goapp |
| 180 | +2. cd gopapp |
| 181 | +3. go install github.com/ibmdb/go_ibm_db/installer@latest |
| 182 | + or |
| 183 | + go install github.com/ibmdb/go_ibm_db/[email protected] |
| 184 | +``` |
| 185 | + |
| 186 | +#### 4.2.2 Manual Installation by using git clone. |
| 187 | +``` |
| 188 | +1. mkdir goapp |
| 189 | +2. cd goapp |
| 190 | +3. git clone https://github.com/ibmdb/go_ibm_db/ |
| 191 | +``` |
| 192 | + |
| 193 | +### 4.3 Download clidriver |
| 194 | + |
| 195 | +Download clidriver in your system, go to installer folder where go_ibm_db is downloaded in your system, use below command: |
| 196 | +(Example: C:\Users\uname\go\src\github.com\ibmdb\go_ibm_db\installer or C:\goapp\go_ibm_db\installer |
| 197 | + where uname is the username ) and run setup.go file (go run setup.go). |
| 198 | + |
| 199 | + |
| 200 | +### 4.4 Set environment variables to clidriver directory path |
| 201 | + |
| 202 | +#### 4.4.1 Manual |
| 203 | +``` |
| 204 | +set IBM_DB_HOME=C:\Users\uname\go\src\github.com\ibmdb\clidriver |
| 205 | +set PATH=%PATH%;C:\Users\uname\go\src\github.com\ibmdb\clidriver\bin |
| 206 | +or |
| 207 | +set PATH=%PATH%;%IBM_DB_HOME%\bin |
| 208 | +``` |
| 209 | + |
| 210 | +### 4.4.2 Script file |
| 211 | +``` |
| 212 | +cd .../go_ibm_db/installer |
| 213 | +Run setenvwin.bat |
| 214 | +``` |
| 215 | +It's Done. |
| 216 | + |
| 217 | +4. Download platform specific clidriver from https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ , untar/unzip it and set `IBM_DB_HOME` environmental variable to full path of extracted 'clidriver' directory, for example if clidriver is extracted as: `/home/mysystem/clidriver`, then set system level environment variable `IBM_DB_HOME=/home/mysystem/clidriver`. |
| 218 | + |
| 219 | + |
| 220 | + |
| 221 | +## <a name="m1chip"></a> 5. Steps to install ibm_db on MacOS M1/M2 Chip system (arm64 architecture) |
| 222 | +**Warning:** If you use the ARM version of homebrew (as recommended for M1/M2 chip systems) you will get the following error message: |
| 223 | +``` |
| 224 | +$ brew install gcc-12 |
| 225 | +Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)! |
| 226 | +Please create a new installation in /opt/homebrew using one of the |
| 227 | +"Alternative Installs" from: |
| 228 | + https://docs.brew.sh/Installation |
| 229 | +You can migrate your previously installed formula list with: |
| 230 | + brew bundle dump |
| 231 | +``` |
| 232 | +Install `gcc@12` using homebrew `(note: the x86_64 version of homebrew is needed for this, not the recommended ARM based homebrew)`. The clearest instructions on how to install and use the `x86_64` version of `homebrew` is by following below steps: |
| 233 | +* My arm64/M1 brew is installed here: |
| 234 | +``` |
| 235 | + $ which brew |
| 236 | + /opt/homebrew/bin/brew |
| 237 | +``` |
| 238 | +* Step 1. Install x86_64 brew under /usr/local/bin/brew |
| 239 | + `arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"` |
| 240 | +* Step 2. Create an alias for the x86_64 brew |
| 241 | + I added this to my ~/.bashrc as below: |
| 242 | +``` |
| 243 | + # brew hack for x86_64 |
| 244 | + alias brew64='arch -x86_64 /usr/local/bin/brew' |
| 245 | +``` |
| 246 | +* Then install gcc@12 using the x86_64 homebrew: |
| 247 | +``` |
| 248 | + brew64 install gcc@12 |
| 249 | +``` |
| 250 | +* Now find location of `lib/gcc/12/libstdc++.6.dylib` file in your system. It should be inside `/usr/local/homebrew/lib/gcc/12` or `/usr/local/lib/gcc/12` or `/usr/local/homebrew/Cellar/gcc@12/12.2.0/lib/gcc/12` or something similar. You need to find the correct path. |
| 251 | +Suppose path of gcc lib is `/usr/local/homebrew/lib/gcc/12`. Then update your .bashrc/.zshrc file with below line |
| 252 | +``` |
| 253 | +export DYLD_LIBRARY_PATH=/usr/local/homebrew/lib/gcc/12:$DYLD_LIBRARY_PATH |
| 254 | +``` |
0 commit comments