Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load dynamic library 'pdo_snowflake.so' #195

Closed
brettpappas opened this issue Aug 28, 2019 · 13 comments
Closed

Unable to load dynamic library 'pdo_snowflake.so' #195

brettpappas opened this issue Aug 28, 2019 · 13 comments
Assignees
Labels
question Issue is a usage/other question rather than a bug

Comments

@brettpappas
Copy link

I have tried everything I can think of to build the pdo extension for my docker image with no luck. I always end up with the following error when starting up php:

NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_snowflake.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so 
(Error relocating /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so: setcontext: symbol not found), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so.so 
(Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so.so: No such file or directory)) in Unknown on line 0

Here is my setup:
Dockerfile uses php:7.3-fpm-alpine which pulls down PHP 7.3.8.

The script for building pdo_snowflake is:

export PHP_HOME=/usr/local \
&& git clone https://github.com/snowflakedb/pdo_snowflake.git \
&& cd pdo_snowflake \
&& ./scripts/build_pdo_snowflake.sh \
&& cp modules/pdo_snowflake.so /usr/local/lib/php/extensions/no-debug-non-zts-*/ \
&& cp ./libsnowflakeclient/cacert.pem /usr/local/etc/php/cacert.pem \

I then include a pdo_snowflake.ini file with:

extension=pdo_snowflake.so
pdo_snowflake.cacert=/usr/local/etc/php/cacert.pem

You can see from the error that it looks for the extension at /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so which I can confirm is there:

bash-5.0# ls -la /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so
-rwxr-xr-x    1 root     root       4565576 Aug 28 19:16 /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so

Not sure what else I can try to get this extension working.

@brettpappas
Copy link
Author

Here is what I get when trying to load the extension from the command line (using the install folder instead of the php extensions folder where I copied the extension to):

bash-5.0# pwd
/var/www/html/pdo_snowflake

bash-5.0# $PHP_HOME/bin/php -dextension=modules/pdo_snowflake.so -m
Cannot load Zend OPcache - it was already loaded
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_snowflake.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so (Error relocating /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so: setcontext: symbol not found), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_snowflake.so.so: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/pdo_snowflake.so' (tried: modules/pdo_snowflake.so (Error relocating modules/pdo_snowflake.so: setcontext: symbol not found), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/modules/pdo_snowflake.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/modules/pdo_snowflake.so.so: No such file or directory)) in Unknown on line 0
[PHP Modules]
apcu
bcmath
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gnupg
hash
iconv
json
libxml
mbstring
mongodb
mysqlnd
openssl
pcre
PDO
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
redis
Reflection
session
SimpleXML
soap
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

@merlijnbuit
Copy link

I have exactly the same issue. Did you already found a solution?

@phpguru
Copy link

phpguru commented Dec 8, 2020

This may or may not be the issue, but according to the README, this extension requires PHP 7.2.

@mortezarajabi
Copy link

I have the same issue.

After successful build, I tried to load it in memory to check if it's working

PHP Startup: Unable to load dynamic library 'modules/pdo_snowflake.so' (tried: modules/pdo_snowflake.so (dlopen(modules/pdo_snowflake.so, 9): Symbol not found: __ZTVN5azure12storage_lite15tinyxml2_parserE Referenced from: modules/pdo_snowflake.so

@carcinocron
Copy link

same error:

php -v
PHP 7.2.32 (cli) (built: Jul 10 2020 00:06:00) ( NTS )
$PHP_HOME/bin/php -dextension=modules/pdo_snowflake.so -m | grep pdo_snowflake
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/pdo_snowflake.so' (tried: modules/pdo_snowflake.so (dlopen(modules/pdo_snowflake.so, 9): image not found), /usr/local/lib/php/pecl/20170718/modules/pdo_snowflake.so.so (dlopen(/usr/local/lib/php/pecl/20170718/modules/pdo_snowflake.so.so, 9): image not found)) in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_snowflake.so' (tried: modules/pdo_snowflake.so (dlopen(modules/pdo_snowflake.so, 9): image not found), /usr/local/lib/php/pecl/20170718/modules/pdo_snowflake.so.so (dlopen(/usr/local/lib/php/pecl/20170718/modules/pdo_snowflake.so.so, 9): image not found)) in Unknown on line 0

@zscally
Copy link

zscally commented Dec 22, 2020

I am getting the same error:

Docker container: php:7.4-fpm-alpine

/usr/local/lib/php/extensions/no-debug-non-zts-20190902 # php -v
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_snowflake.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_snowflake.so (Error relocating /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_snowflake.so: setcontext: symbol not found), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_snowflake.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_snowflake.so.so: No such file or directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'pdo_snowflake.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_snowflake.so (Error relocating /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_snowflake.so: setcontext: symbol not found), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_snowflake.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_snowflake.so.so: No such file or directory)) in Unknown on line 0
PHP 7.4.13 (cli) (built: Dec  1 2020 04:51:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies

Please note that all our error messages including the comments above from php 7.2 seem to be trying to load in the module with "pdo_snowflake.so.so" I have even tried renaming the file to this .so.so with no luck.

Here are my dependencies needed to run the build for PDO snowflake

# We now need to install the snowflake PDO Driver and its dependencies
RUN apk add --no-cache \
        alpine-sdk \
        gcc \
        cmake \
        nano \
        autoconf \
        make \    
    ;

# Pull the Snowflake PDO repo
RUN git clone https://github.com/snowflakedb/pdo_snowflake.git ~/pdo_snowflake
RUN cd ~/pdo_snowflake \
    && export PHP_HOME=/usr/local/bin \
    && bash scripts/build_pdo_snowflake.sh \
    ;

@tegansnyder
Copy link

tegansnyder commented Sep 15, 2021

If you run the ldd command against the pdo_snowflake.so binary it will tell you what symbols you are missing. For instance im trying this on alpine image and getting:

/usr/local/lib/php/extensions/no-debug-non-zts-20190902 # ldd pdo_snowflake.so
	/lib/ld-musl-x86_64.so.1 (0x7feb95fd9000)
	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x7feb95492000)
	libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7feb95fd9000)
Error relocating pdo_snowflake.so: _ZNSt13random_device9_M_getvalEv: symbol not found

I think its because the alpine images use musl in place of glibc. For me the fix was switching from alpine based php images to debian based.

@c00p3r
Copy link

c00p3r commented Jul 4, 2022

same error
php:7.4-fpm-alpine

# clone pdo_snowflake repo
RUN mkdir /tmp/snowflake \
    && git clone https://github.com/snowflakedb/pdo_snowflake.git /tmp/snowflake

# run the compile command
# move the compiled lib and cert to extensions dir
RUN export PHP_HOME=/usr/local \
    && bash /tmp/snowflake/scripts/build_pdo_snowflake.sh \
    && cp /tmp/snowflake/libsnowflakeclient/cacert.pem /tmp/snowflake/modules/pdo_snowflake.so /usr/local/lib/php/extensions/no-debug-non-zts-*/

@c00p3r
Copy link

c00p3r commented Jul 4, 2022

pdo_snowflake.so.so: No such file or directory

did u notice that it has '.so.so' (double) in the error message?
I get the same
isn't that strange?
maybe that's what causing error?
Screenshot at Jul 04 15-37-12

@c00p3r
Copy link

c00p3r commented Jul 5, 2022

Just gonna drop my dockerfile here
for those who's struggling
(I know you do :) I was for 2 days)
It includes official pdo_snowflake driver, odbc and pdo-odbc php extensions, phpredis and xdebug
with this - u're 100% ready to install the package https://github.com/yoramdelangen/laravel-pdo-odbc
IT CANNOT USE ALPINE IMAGE!!!
because pdo_snowflake driver builds wrong

FROM php:7.4-fpm

WORKDIR /var/www

# install the jq library to support the snowflake build
RUN apt-get -y update \
    && apt-get -y install --no-install-recommends  \
    libicu-dev  \
    g++ \
    bash \
    httpie \
    unzip \
    libzip-dev \
    autoconf \
    make \
    jq \
    git \
    unixodbc \
    unixodbc-dev -y \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

RUN docker-php-ext-configure intl \
    && docker-php-ext-install intl pdo_mysql pcntl bcmath zip \
    && docker-php-ext-enable intl

# clone pdo_snowflake repo
RUN mkdir /tmp/snowflake \
    && git clone https://github.com/snowflakedb/pdo_snowflake.git /tmp/snowflake

# run the compile command
# move the compiled lib and cert to extensions dir
RUN export PHP_HOME=/usr/local \
    && bash /tmp/snowflake/scripts/build_pdo_snowflake.sh \
    && cp /tmp/snowflake/libsnowflakeclient/cacert.pem /tmp/snowflake/modules/pdo_snowflake.so /usr/local/lib/php/extensions/no-debug-non-zts-*/ \
    && rm -rf /tmp/snowflake

COPY ./docker/local/api/pdo_snowflake.ini /usr/local/etc/php/conf.d/pdo_snowflake.ini

RUN set -ex; \
    docker-php-source extract; \
    { \
        echo '# https://github.com/docker-library/php/issues/103#issuecomment-353674490'; \
        echo 'AC_DEFUN([PHP_ALWAYS_SHARED],[])dnl'; \
        echo; \
        cat /usr/src/php/ext/odbc/config.m4; \
    } > temp.m4; \
    mv temp.m4 /usr/src/php/ext/odbc/config.m4; \
    docker-php-ext-configure odbc --with-unixODBC=shared,/usr; \
    docker-php-ext-install odbc; \
    docker-php-source delete

RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \
    && docker-php-ext-install pdo_odbc

RUN pecl install -o -f redis \
    && rm -rf /tmp/pear \
    && docker-php-ext-enable redis

ARG INSTALL_XDEBUG
ARG REMOTE_HOST_IP

RUN if [ "$INSTALL_XDEBUG" = "true" ];  \
    then \
    pecl install xdebug; \
    docker-php-ext-enable xdebug; \
fi

ENV COMPOSER_ALLOW_SUPERUSER 1

RUN curl -sS https://getcomposer.org/installer |  php -- --install-dir=/usr/local/bin --filename=composer

COPY ./docker/local/api/php.ini $PHP_INI_DIR/php.ini

COPY ./docker/local/api/www.conf $PHP_INI_DIR/../php-fpm.d/www.conf

RUN mkdir tests

COPY composer.* ./

COPY .env.example .env

RUN composer install 

COPY ./docker/local/api/entrypoint.sh /usr/local/bin

RUN ["chmod", "+x", "/usr/local/bin/entrypoint.sh"]

ENTRYPOINT ["/usr/local/bin/entrypoint.sh", "php-fpm"]

@ghost
Copy link

ghost commented Aug 16, 2022

there is no such file in git repo like this "/modules/pdo_snowflake.so"

@oranges13
Copy link

I was having this same issue with php:7.2-fpm docker image and the key was running the compile script with bash: bash scripts/build_pdo_snowflake.sh

@sfc-gh-igarish sfc-gh-igarish added the question Issue is a usage/other question rather than a bug label Mar 30, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Feb 23, 2024
@sfc-gh-dszmolka
Copy link
Contributor

hi - trying to cleaning up the old issues here.
so if i get this correctly, the issues is resolved now (except maybe for the Alpine scenario which now has a separate issue raised)
we also documented the prerequsites for building the .so somewhere along the road.
closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issue is a usage/other question rather than a bug
Projects
None yet
Development

No branches or pull requests