SkyAPM / SkyAPM-php-sdk

Replaced by https://github.com/apache/skywalking-php
https://skywalking.apache.org/
Apache License 2.0
421 stars 104 forks source link

skywalking.so: undefined symbol: _ZNSt20regex_token_iteratorIN9__gnu_cxx17__normal_iteratorIPKcSsEEcSt12regex_traitsIcEEneERKS7_ #292

Closed mfurlend closed 3 years ago

mfurlend commented 4 years ago

Describe the bug I was able to build skywalking and include it php.ini, but when php attempts to load it I get this error: PHP Warning: PHP Startup: Unable to load dynamic library 'skywalking' (tried: /opt/remi/php73/root/usr/lib64/php/modules/skywalking (/opt/remi/php73/root/usr/lib64/php/modules/skywalking: cannot open shared object file: No such file or directory), /opt/remi/php73/root/usr/lib64/php/modules/skywalking.so (/opt/remi/php73/root/usr/lib64/php/modules/skywalking.so: undefined symbol: _ZNSt20regex_token_iteratorIN9__gnu_cxx17__normal_iteratorIPKcSsEEcSt12regex_traitsIcEEneERKS7_)) in Unknown on line 0

To Reproduce (in a dockerfile, using a Centos 7 base):

FROM dockerized_base
RUN  yum install -y  \
    ImageMagick-6.7.8.9-15.el7_2.i686 \
    httpd-devel.x86_64 \
    php73-mod_php  \
    php73-php-bcmath.x86_64 \
    php73-php-cli.x86_64 \
    php73-php-common.x86_64 \
    php73-php-devel.x86_64 \
    php73-php-gd.x86_64 \
    php73-php-imap.x86_64 \
    php73-php-intl.x86_64 \
    php73-php-json.x86_64 \
    php73-php-mbstring.x86_64 \
    php73-php-mcrypt.x86_64 \
    php73-php-mysqlnd.x86_64 \
    php73-php-odbc.x86_64 \
    php73-php-opcache.x86_64 \
    php73-php-pdo-dblib.x86_64 \
    php73-php-pdo.x86_64 \
    php73-php-process.x86_64 \
    php73-php-snmp.x86_64 \
    php73-php-soap.x86_64 \
    php73-php-tidy.x86_64 \
    php73-php-xml.x86_64 \
    php73-php-xmlrpc.x86_64 \
    php73-php-pecl-igbinary.x86_64 \
    php73-php-pecl-memcached.x86_64 \
    php73-php-pecl-imagick.x86_64 \
    cmake3

ENV GRPC_RELEASE_TAG v1.33.2
ENV PROTOBUF_RELEASE_TAG 3.14.x

RUN mkdir -p /var/local/git && cd /var/local/git \
    && git clone --depth 1 -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc \
    && cd /var/local/git/grpc && git submodule update --init --recursive \
    && echo "--- clone protobuf ---" \
    && git clone --depth 1 -b ${PROTOBUF_RELEASE_TAG} https://github.com/protocolbuffers/protobuf.git /var/local/git/protobuf \
    && cd /var/local/git/protobuf && git submodule update --init --recursive \
    && echo "--- installing protobuf ---" \
    && cd /var/local/git/protobuf \
    && ./autogen.sh && ./configure \
    && make -j$(nproc) && make install && ldconfig \
    && echo "--- installing grpc ---" \
    && cd /var/local/git/grpc \
    && mkdir -p cmake/build \
    && cd cmake/build \
    && cmake3 ../.. -DBUILD_SHARED_LIBS=ON -DgRPC_INSTALL=ON \
    && make -j$(nproc) && make install && make clean && ldconfig \
    && cd / \
    && rm -fr /var/local/git/grpc \
    && rm -fr /var/local/git/protobuf

RUN yum install -y php73-php-devel curl-devel
RUN curl -Lo v4.0.0.tar.gz https://github.com/SkyAPM/SkyAPM-php-sdk/archive/v4.0.0.tar.gz && \
    tar zxvf v4.0.0.tar.gz

ENV LD_LIBRARY_PATH="/usr/local/lib/;/usr/local/lib64/"

RUN set -ex \
    && echo "--- installing skywalking php ---" \
    && cd SkyAPM-php-sdk-4.0.0 \
    && /opt/remi/php73/root/usr/bin/phpize && ./configure --with-php-config=/opt/remi/php73/root/usr/bin/php-config && make && make install

COPY skywalking.ini /etc/opt/remi/php73/php.d/50-skywalking.ini

ENTRYPOINT ["httpd", "-D", "FOREGROUND"]

**PHP 7.3

heyanlong commented 4 years ago

The GCC version?

garysdevil commented 3 years ago

I get the same problem php: 7.1 SkyAPM-php-sdk: 4.0 Instruction: https://github.com/SkyAPM/SkyAPM-php-sdk/blob/v4.0.0/docs/install.md System: Linux version 4.14.62-65.117.amzn1.x86_64 (mockbuild@gobi-build-60009) (gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)) image Problem: image

heyanlong commented 3 years ago

What does ldd return?

garysdevil commented 3 years ago

What does ldd return?

27695abf0c42601a88ef7ec4d2f6ae7 根据以上截图大概是protobuf的版本问题,protobuf版本问题已经解决,如下图所示,但依然出现同样的问题。 image

我今早set -e 把部署脚本放进文件里,然后重新编译了一次4.1,这次最后进入SkyAPM-php-sdk-4.1.0进行make时失败了 image

heyanlong commented 3 years ago

make的错误是因为没成功安装protobuf

garysdevil commented 3 years ago

I resolved the problem finally. Process: The libproto* of Dynamic library was put into /usr/local/lib64 when did "Install Protobuf", but /usr/local/lib64 is not configued as the searching path of dynamic link library. Configued that,ldconfig, then make SkyAPM-php-sdk again

garysdevil commented 3 years ago

make的错误是因为没成功安装protobuf

对的,谢谢。 唉,没学过C++编译的窘境,普及了一下相关知识。

heyanlong commented 3 years ago

需要确认这两个环境变量运行和编译时是一样的。要不然可能加载不到动态库

LD_RUN_PATH
LD_LIBRARY_PATH