pecl-database-ibm_db2 icon indicating copy to clipboard operation
pecl-database-ibm_db2 copied to clipboard

cannot find -ldb2 and execute pecl install ibm_db2 command on docker container

Open MaraRuizG opened this issue 3 years ago • 6 comments
trafficstars

Logs: => ERROR [16/18] RUN pecl install ibm_db2 4.7s

[16/18] RUN pecl install ibm_db2: #20 1.910 downloading ibm_db2-2.1.5.tgz ... #20 1.912 Starting to download ibm_db2-2.1.5.tgz (196,974 bytes) #20 1.984 .........................................done: 196,974 bytes #20 2.231 9 source files, building #20 2.231 running: phpize #20 2.237 Configuring for: #20 2.237 PHP Api Version: 20180731 #20 2.237 Zend Module Api No: 20180731 #20 2.237 Zend Extension Api No: 320180731 #20 2.529 DB2 Installation Directory? : building in /tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5 #20 2.529 running: /tmp/pear/temp/ibm_db2/configure --with-php-config=/usr/local/bin/php-config --with-IBM_DB2= #20 2.601 checking for grep that handles long lines and -e... /bin/grep #20 2.603 checking for egrep... /bin/grep -E #20 2.605 checking for a sed that does not truncate output... /bin/sed #20 2.612 checking for cc... cc #20 2.650 checking whether the C compiler works... yes #20 2.650 checking for C compiler default output file name... a.out #20 2.675 checking for suffix of executables... #20 2.701 checking whether we are cross compiling... no #20 2.716 checking for suffix of object files... o #20 2.731 checking whether we are using the GNU C compiler... yes #20 2.746 checking whether cc accepts -g... yes #20 2.772 checking for cc option to accept ISO C89... none needed #20 2.790 checking how to run the C preprocessor... cc -E #20 2.813 checking for icc... no #20 2.820 checking for suncc... no #20 2.848 checking whether cc understands -c and -o together... yes #20 2.848 checking for system library directory... lib #20 2.857 checking if compiler supports -R... no #20 2.882 checking if compiler supports -Wl,-rpath,... yes #20 2.920 checking build system type... aarch64-unknown-linux-gnu #20 2.920 checking host system type... aarch64-unknown-linux-gnu #20 2.920 checking target system type... aarch64-unknown-linux-gnu #20 2.946 checking for PHP prefix... /usr/local #20 2.946 checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib #20 2.946 checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20180731 #20 2.946 checking for PHP installed headers prefix... /usr/local/include/php #20 2.967 checking if debug is enabled... no #20 2.986 checking if zts is enabled... no #20 2.986 checking for re2c... re2c #20 2.991 checking for re2c version... 2.0.3 (ok) #20 2.991 checking for gawk... no #20 2.992 checking for nawk... nawk #20 2.993 checking if nawk is broken... no #20 2.993 checking for IBM_DB2 support... yes, shared #20 3.002 checking PHP... Detected 64-bit PHP #20 3.002 checking IBM_DB_HOME location... /opt/ibm/clidriver #20 3.002 checking Looking for DB2 CLI libraries... checking in /opt/ibm/clidriver... #20 3.002 checking in /opt/ibm/clidriver/lib64... #20 3.002 checking in /opt/ibm/clidriver/lib... found #20 3.002 checking for DB2 CLI include files in default path... checking in /opt/ibm/clidriver... found in /opt/ibm/clidriver #20 3.012 checking for ld used by cc... /usr/bin/ld #20 3.014 checking if the linker (/usr/bin/ld) is GNU ld... yes #20 3.014 checking for /usr/bin/ld option to reload object files... -r #20 3.016 checking for BSD-compatible nm... /usr/bin/nm -B #20 3.016 checking whether ln -s works... yes #20 3.017 checking how to recognize dependent libraries... pass_all #20 3.088 checking for ANSI C header files... yes #20 3.107 checking for sys/types.h... yes #20 3.128 checking for sys/stat.h... yes #20 3.150 checking for stdlib.h... yes #20 3.174 checking for string.h... yes #20 3.197 checking for memory.h... yes #20 3.220 checking for strings.h... yes #20 3.243 checking for inttypes.h... yes #20 3.266 checking for stdint.h... yes #20 3.291 checking for unistd.h... yes #20 3.314 checking dlfcn.h usability... yes #20 3.322 checking dlfcn.h presence... yes #20 3.322 checking for dlfcn.h... yes #20 3.326 checking the maximum length of command line arguments... 1572864 #20 3.377 checking command to parse /usr/bin/nm -B output from cc object... ok #20 3.381 checking for objdir... .libs #20 3.381 checking for ar... ar #20 3.381 checking for ranlib... ranlib #20 3.381 checking for strip... strip #20 3.435 checking if cc supports -fno-rtti -fno-exceptions... no #20 3.436 checking for cc option to produce PIC... -fPIC #20 3.453 checking if cc PIC flag -fPIC works... yes #20 3.499 checking if cc static flag -static works... yes #20 3.519 checking if cc supports -c -o file.o... yes #20 3.528 checking whether the cc linker (/usr/bin/ld) supports shared libraries... yes #20 3.548 checking whether -lc should be explicitly linked in... no #20 3.558 checking dynamic linker characteristics... GNU/Linux ld.so #20 3.558 checking how to hardcode library paths into programs... immediate #20 3.560 checking whether stripping libraries is possible... yes #20 3.561 checking if libtool supports shared libraries... yes #20 3.561 checking whether to build shared libraries... yes #20 3.561 checking whether to build static libraries... no #20 3.663 #20 3.663 creating libtool #20 3.676 appending configuration tag "CXX" to libtool #20 3.722 configure: creating ./config.status #20 3.755 config.status: creating config.h #20 3.777 running: make #20 3.779 /bin/bash /tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5/libtool --mode=compile cc -I. -I/tmp/pear/temp/ibm_db2 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5/include -I/tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5/main -I/tmp/pear/temp/ibm_db2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/opt/ibm/clidriver/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/ibm_db2/ibm_db2.c -o ibm_db2.lo #20 3.825 mkdir .libs #20 3.827 cc -I. -I/tmp/pear/temp/ibm_db2 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5/include -I/tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5/main -I/tmp/pear/temp/ibm_db2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/opt/ibm/clidriver/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/ibm_db2/ibm_db2.c -fPIC -DPIC -o .libs/ibm_db2.o #20 3.876 In file included from /opt/ibm/clidriver/include/sqlcli1.h:45, #20 3.876 from /tmp/pear/temp/ibm_db2/php_ibm_db2.h:45, #20 3.876 from /tmp/pear/temp/ibm_db2/ibm_db2.c:35: #20 3.876 /opt/ibm/clidriver/include/sqlcli.h:876: warning: "ODBCVER" redefined #20 3.876 876 | #define ODBCVER 0x0380 #20 3.876 | #20 3.876 In file included from /usr/local/include/php/Zend/zend_config.h:1, #20 3.876 from /usr/local/include/php/Zend/zend_portability.h:43, #20 3.876 from /usr/local/include/php/Zend/zend_types.h:25, #20 3.876 from /usr/local/include/php/Zend/zend.h:27, #20 3.876 from /usr/local/include/php/main/php.h:33, #20 3.876 from /tmp/pear/temp/ibm_db2/ibm_db2.c:31: #20 3.876 /usr/local/include/php/main/../main/php_config.h:2260: note: this is the location of the previous definition #20 3.876 2260 | #define ODBCVER 0x0350 #20 3.876 | #20 4.583 /bin/bash /tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5/libtool --mode=link cc -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5/include -I/tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5/main -I/tmp/pear/temp/ibm_db2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/opt/ibm/clidriver/include -DHAVE_CONFIG_H -g -O2 -o ibm_db2.la -export-dynamic -avoid-version -prefer-pic -module -rpath /tmp/pear/temp/pear-build-defaultuserynMpFT/ibm_db2-2.1.5/modules ibm_db2.lo -Wl,-rpath,/opt/ibm/clidriver/lib/ -L/opt/ibm/clidriver/lib/ -ldb2 #20 4.637 cc -shared .libs/ibm_db2.o -L/opt/ibm/clidriver/lib/ -ldb2 -Wl,-rpath -Wl,/opt/ibm/clidriver/lib/ -Wl,-soname -Wl,ibm_db2.so -o .libs/ibm_db2.so #20 4.640 /usr/bin/ld: skipping incompatible /opt/ibm/clidriver/lib//libdb2.so when searching for -ldb2 #20 4.640 /usr/bin/ld: cannot find -ldb2 #20 4.640 /usr/bin/ld: skipping incompatible /opt/ibm/clidriver/lib//libdb2.so when searching for -ldb2 #20 4.641 collect2: error: ld returned 1 exit status #20 4.641 make: *** [Makefile:199: ibm_db2.la] Error 1 #20 4.645 ERROR: `make' failed


executor failed running [/bin/sh -c pecl install ibm_db2]: exit code: 1 ERROR: Service 'main_php' failed to build : Build failed

MaraRuizG avatar Mar 10 '22 16:03 MaraRuizG

You need to pass a path to the CLI driver (see heading - download it, extract it somewhere) w/ the --with-IBM_DB2= flag, i.e. ``--with-IBM_DB2=/opt/clidriver. I don't use the pecl` frontend, so I don't know how to pass those flags when using it.

NattyNarwhal avatar Mar 10 '22 17:03 NattyNarwhal

Hi, I had already passed this path to the CLI driver before IBM_DB_HOME=/opt/ibm/clidriver LD_LIBRARY_PATH=/opt/ibm/clidriver/lib and still had the error I also tried what you suggested pecl install ibm_db2 --with-IBM_DB2=/opt/ibm/clidriver but I'm getting the same error

MaraRuizG avatar Mar 10 '22 17:03 MaraRuizG

/usr/bin/ld: skipping incompatible /opt/ibm/clidriver/lib//libdb2.so when searching for -ldb2

The linker seems to think it's incompatible. Did you download the correct driver for the architecture you're building?

kadler avatar Mar 10 '22 19:03 kadler

I think so. I'm using a mac with chip M1 and the driver is 64-bit.

MaraRuizG avatar Mar 10 '22 19:03 MaraRuizG

Well, first I don't think they support ARM yet: https://github.com/ibmdb/python-ibmdb/tree/master/IBM_DB/ibm_db#-client-license-for-specific-platform-and-architecture

And downloading the public client from the FTP site shows no:

$ file libdb2.dylib
libdb2.dylib: Mach-O 64-bit dynamically linked shared library x86_64

However, I just realized you're running Docker so none of that matters since the Docker container is Linux and indeed the error message references libdb2.so, not libdb2.dylib.

Apparently Docker for Mac can build and run both x86 and ARM images: https://www.docker.com/press-release/Docker-Desktop-for-M1-powered-Macs

Docker has long supported multi-platform container images with the ability to build and run both x86 and Arm images on Docker Desktop. With this release, developers can build and run end-to-end on the Arm architecture from Docker Desktop on their M1-powered Macs to Arm-based cloud servers such as AWS Graviton 2.

My guess is it defaults to an ARM image, but you'll need to figure out a way to have Docker build an x86 image instead.

kadler avatar Mar 10 '22 19:03 kadler

@MaraRuizG were you able to resolve this ?

praveen-db2 avatar Jun 13 '22 14:06 praveen-db2