Closed wisenrico closed 1 year ago
@wisenrico For above error you may need to set env var as below,
Windows:
set LIB=%IBM_DB_HOME%/lib;%LIB%
AIX:
export LIBPATH=$IBM_DB_HOME/lib:$LIBPATH
MAC:
export DYLD_LIBRARY_PATH=$IBM_DB_HOME/lib:$DYLD_LIBRARY_PATH
Other platforms:
export LD_LIBRARY_PATH=$IBM_DB_HOME/lib:$LD_LIBRARY_PATH
Thank you @praveen-db2. I have tried to export the env vars as following:
export IBM_DB_HOME=/Users/[User]/ruby-ibmdb-master/lib/clidriver
export DYLD_LIBRARY_PATH=$IBM_DB_HOME/lib:$DYLD_LIBRARY_PATH
echo $DYLD_LIBRARY_PATH
/Users/[User]/ruby-ibmdb-master/lib/clidriver/lib:/lib:
but I had no luck:
Detected 64-bit Ruby
Detected platform - MacOS darwin64
extconf.rb:95: warning: already initialized constant DOWNLOADLINK
extconf.rb:45: warning: previous definition of DOWNLOADLINK was here
Detected usage of IBM Data Server Driver package. Ensure you have downloaded 64-bit package of IBM_Data_Server_Driver and retry the 'gem install ibm_db' command
creating gil_release_version.h
creating unicode_support_version.h
checking for SQLConnect() in -ldb2... no
checking for SQLConnect() in -ldb2... no
extconf failure: Unable to locate libdb2.so/a under /Users/[User]/ruby-ibmdb-master/lib/clidriver/lib
Follow the steps below and retry
Step 1: - Install IBM DB2 Universal Database Server/Client
step 2: - Set the environment variable IBM_DB_HOME as below
(assuming bash shell)
export IBM_DB_HOME=<DB2/IBM_Data_Server_Driver installation directory> #(Eg: export IBM_DB_HOME=/opt/ibm/db2/v10)
step 3: - Retry gem install
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
My clidriver
directory looks like this:
@wisenrico do you have gcc installed, if installed check if u have permission for gcc and also make sure developer tools installed.
Unset IBM_DB_HOME and DYLD_LIBRARY_PATH before installing ibm_db as you are not installing clidriver manually
@wisenrico i see you trying to build from IBM_DB_DRIVER dir, if you want to build here, you need to manually install clidriver and set IBM_DB_HOME and DYLD_LIBRARY_PATH, and then try building IBM_DB_DRIVER.
If you do build and install from IBM_DB_Adapter , clidriver will be auto downloaded and installed., so no need to set IBM_DB_HOME and DYLD_LIBRARY_PATH before build and install of gem.
I tried both solutions but none of them work.
When trying to install from adapter I have the same problem:
echo $DYLD_LIBRARY_PATH
echo $IBM_DB_HOME
~/ruby-ibmdb-5.4.1/IBM_DB_Adapter | gem install ibm_db
Building native extensions. This could take a while...
ERROR: Error installing ibm_db:
ERROR: Failed to build gem native extension.
current directory: /Users/[User]/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/ibm_db-5.4.1/ext
/Users/[User]/.rbenv/versions/3.2.1/bin/ruby -I /Users/[User]/.rbenv/versions/3.2.1/lib/ruby/3.2.0 extconf.rb
extconf.rb:95: warning: already initialized constant DOWNLOADLINK
extconf.rb:45: warning: previous definition of DOWNLOADLINK was here
extconf.rb:183: warning: already initialized constant IBM_DB_HOME
extconf.rb:21: warning: previous definition of IBM_DB_HOME was here
extconf.rb:185: warning: already initialized constant IBM_DB_INCLUDE
extconf.rb:166: warning: previous definition of IBM_DB_INCLUDE was here
extconf.rb:186: warning: already initialized constant IBM_DB_LIB
extconf.rb:167: warning: previous definition of IBM_DB_LIB was here
Detected 64-bit Ruby
Detected platform - MacOS darwin64
Environment variable IBM_DB_HOME is not set. Downloading and setting up the DB2 client driver
creating gil_release_version.h
creating unicode_support_version.h
checking for SQLConnect() in -ldb2... no
checking for SQLConnect() in -ldb2... no
extconf failure: Unable to locate libdb2.so/a under /Users/[User]/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/ibm_db-5.4.1/ext/../lib/clidriver/lib
Follow the steps below and retry
The indicated directory contains:
@wisenrico below are steps i follow to build and install ibm_db driver and adapter from source.
BUILD ibm_db gem from sources (ibm_db-x.x.x.tar.gz):
1. mkdir ROR3x (Assuming I am at home directory.)
cd ROR3x
Download source from Github via clone or download tar.gz and untar the same
https://github.com/ibmdb/ruby-ibmdb
2. Build the driver inside ruby-ibmdb/IBM_DB_Adapter/ibm_db:
gem list (To list all gems installed, if 'zip' gem not installed install it)
gem install zip
- $ unset IBM_DB_HOME (To unset IBM_DB_HOME to nothing before installng ruby ibm_db)
- $ rm -rf ruby-ibmdb/IBM_DB_Adapter/ibm_db/lib/clidriver* (Just to remove clidriver if its installed before)
- $ cd ruby-ibmdb/IBM_DB_Adapter/ibm_db/ext
- $ rm Makefile ibm_db.so *.log
- $ ruby extconf.rb
- $ make (On Linux) (This also download and install clidriver from internet and install at ruby_ibmdb/IBM_DB_Adapter/ibm_db/lib)
(or)
ridk exec make (On windows)
Build the ibm_db gem
- $ rm ../lib/ibm_db.so
- $ cp ibm_db.so ../lib (Note: ibm_db.so will be generated under ~/ROR3x/ruby-ibmdb/IBM_DB_Adapter/ibm_db/ext/ when 'make' is run. And should be copied to lib dir which is under path ~/ROR3x/ruby-ibmdb/IBM_DB_Adapter/ibm_db/lib)
- $ cd .. (i.e to ~/ROR3x/ruby-ibmdb/IBM_DB_Adapter/ibm_db)
- $ gem build IBM_DB.gemspec (This will create gem file ibm_db-5.x.0.gem)
cd ../../../
gem install --local ruby-ibmdb/IBM_DB_Adapter/ibm_db/ibm_db-5.x.0.gem
I tried again with no success at all. Analyzing the libdb2.dylib
file I see that the arm64 architecture is not listed.
/Users/[User]/rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/ibm_db-5.4.1/lib/clidriver/lib/libdb2.dylib: Mach-O 64-bit dynamically linked shared library x86_64
Could this be the issue here? M1 is arm64, not x86_64.
Sorry clidriver is not supported on arm64 architecture.
@wisenrico You can install x86_64 version (Intel Only version) of ruby on M1 Chip system and then install ibmdb. Thanks.
@wisenrico can we close this issue ?
Yes the issue can be closed.
The workaround I found is to use Docker as host. In this case, I have installed the gem by using platform: linux/amd64
in my docker-compose.yml
file.
I am facing this blocking error while trying to install the
ibm_db
gem or trying to runrake
command with the driver:How to reproduce
master
branchlib
directory as sibling ofIBM_DB_Driver
(I'm getting a "'rename': No such file or directory @ rb_file_s_rename error" otherwise)rake
command intoIBM_DB_Driver
directoryEnvironment
MacBook Pro M1 macOS 13.4 (22F66)
Output
Notes
dsdriver
and pointingIBM_DB_HOME
var to its directorylibdb2.so
doesn't exist intoclidriver
generated directory by I can find it aslibdb2.dylib