SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
251 stars 73 forks source link

Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/src/app/node_modules/node-rfc/lib/binding/sapnwrfc.node) #165

Closed JosephJeffs closed 4 years ago

JosephJeffs commented 4 years ago

On trying to move to latest version of node-rfc. We have been able to get 1.2.0 working. I have not been able to get the library to load with any release including and above 2.0. We are using version 7.50 of the SDK.

I am running on docker and have tried a number of base images including: node:10 node:14 node:14-alpine ubuntu:16.04

I can get the container to build however when I run the application I get:

/usr/src/app/node_modules/node-rfc/lib/wrapper/noderfc-bindings.js:46
    throw ex;
    ^

Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/src/app/node_modules/node-rfc/lib/binding/sapnwrfc.node)

 The SAP NW RFC SDK could not be loaded, check the installation: http://sap.github.io/node-rfc/install.html#sap-nw-rfc-sdk-installation
environment: {
  "platform": {
    "name": "linux",
    "arch": "x64",
    "release": "4.19.76-linuxkit"
  },
  "env": {
    "SAPNWRFC_HOME": "/usr/local/sap/nwrfcsdk",
    "RFC_INI": ""
  },
  "versions": {
    "http_parser": "2.9.3",
    "node": "10.22.0",
    "v8": "6.8.275.32-node.58",
    "uv": "1.34.2",
    "zlib": "1.2.11",
    "brotli": "1.0.7",
    "ares": "1.15.0",
    "modules": "64",
    "nghttp2": "1.41.0",
    "napi": "6",
    "openssl": "1.1.1g",
    "icu": "64.2",
    "unicode": "12.1",
    "cldr": "35.1",
    "tz": "2019c"
  }
}

    at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/usr/src/app/node_modules/node-rfc/lib/wrapper/noderfc-bindings.js:37:49)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/usr/src/app/node_modules/node-rfc/lib/index.js:13:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)

I have tried loading apt-get install libstdc++6 but it is already at the latest version.

The Dockerfile I am using is

FROM node:10

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

# copy rfc libraries
RUN mkdir -p /usr/local/sap/nwrfcsdk
ENV SAPNWRFC_HOME /usr/local/sap/nwrfcsdk

COPY ./nwrfcsdk /usr/local/sap/nwrfcsdk

RUN printf "# include nwrfcsdk\n/usr/local/sap/nwrfcsdk/lib" > /etc/ld.so.conf.d/nwrfcsdk.conf

RUN ldconfig

# set registry for SAP library needed for Hana client
RUN npm config set @sap:registry https://npm.sap.com

RUN npm install

# If you are building your code for production
# RUN npm install --only=production

# Bundle app source
COPY . .

EXPOSE 8000
CMD [ "npm", "start" ]

Any help you could offer would be most welcome.

bsrdjan commented 4 years ago

The node-rfc 2 is built on Ubuntu 20, which apparently has a newer glibc version.

You can upgrade the libstdc, like described here for example: https://stackoverflow.com/questions/44773296/libstdc-so-6-version-glibcxx-3-4-20-not-found, or build the node-rfc from source on your Linux based docker image.

Here image the node-rfc is built on:

#
# Build:
# docker build -f Dockerfile-node -t rfcqa-node .
# docker run --name rfcqa-node -v /home/test/src:/home/www-admin/src -it rfcqa-node
#
# Run:
# docker start -ai rfcqa
#

FROM ubuntu:latest

LABEL maintainer="srdjan.boskovic@.com"
LABEL version="1.0"
LABEL description="RFM Connectors QA"

ARG adminuser=www-admin
ARG nwrfc_local=/usr/local/sap
ARG venv_base=/home/${adminuser}/.virtualenvs
ARG dev_tools="sudo curl wget git unzip vim tree tmux"
ARG dev_libs="build-essential make libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev"

# os update and packages
RUN \
  sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
  apt update && apt install -y locales ${dev_tools}

# timezone # https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes
ENV TZ=Europe/Berlin
RUN locale-gen de_DE && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Add admin user
RUN \
  adduser --disabled-password --gecos "" ${adminuser} && \
  usermod -aG www-data,sudo ${adminuser} && \
  echo "${adminuser} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER ${adminuser}
WORKDIR /home/${adminuser}
RUN printf "alias e=exit\nalias ..=cd..\nalias :q=exit\nalias ll='ls -l'\nalias la='ls -la'\n" > .bash_aliases
RUN printf "\n# colors\nexport TERM=xterm-256color\n" >> ~/.bashrc

# git configuration
RUN \
  git config --global http.sslVerify false && \
  git config --global user.name bsrdjan && \
  git config --global user.email srdjan.boskovic@sap.com

# essentials
RUN sudo apt install -y ${dev_libs}

# cmake
RUN cd /tmp && \
  CMAKE_VERSION=$(curl -s https://api.github.com/repos/Kitware/CMake/releases/latest | grep '"tag_name"' | sed -E 's/.*"v([^"]+)".*/\1/') && \
  wget -q https://github.com/Kitware/CMake/releases/latest/download/cmake-${CMAKE_VERSION}.tar.gz && \
  tar -xzvf cmake-${CMAKE_VERSION}.tar.gz && \
  cd cmake-${CMAKE_VERSION} && \
  ./bootstrap && \
  make -j4 && sudo make install

# sap nw rfc lib
RUN printf "\n# nwrfc sdk \n" >> ~/.bashrc
RUN printf "export SAPNWRFC_HOME=${nwrfc_local}/nwrfcsdk \n" >> ~/.bashrc
USER root
RUN mkdir -p ${nwrfc_local}
COPY /SAP/NWRFCSDK-750-PL6/linux/nwrfcsdk ${nwrfc_local}/nwrfcsdk
RUN chmod -R a+r ${nwrfc_local}/nwrfcsdk && chmod -R a+x ${nwrfc_local}/nwrfcsdk/bin
RUN printf "# include nwrfcsdk\n${nwrfc_local}/nwrfcsdk/lib\n" |  tee /etc/ld.so.conf.d/nwrfcsdk.conf
RUN ldconfig && ldconfig -p | grep sap

# pyenv
RUN git clone https://github.com/pyenv/pyenv.git .pyenv
RUN printf 'export PYENV_ROOT="$HOME/.pyenv"\n' >> .bashrc
RUN printf 'export PATH="$PYENV_ROOT/bin:$PATH"\n' >> .bashrc
RUN printf 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi\n' >> .bashrc
ENV PYENV_ROOT /home/${adminuser}/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN pyenv install ${py38}
RUN pyenv install ${py37}
RUN pyenv install ${py36}

# pyenv-virtualenv
RUN git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
RUN printf 'eval "$(pyenv virtualenv-init -)"\n' >> ~/.bashrc
RUN printf 'export PYENV_VIRTUALENV_DISABLE_PROMPT=1\n' >> ~/.bashrc
RUN bash -ic "pyenv virtualenv ${py36} ${py36venv} && pyenv activate ${py36venv} && pip install --upgrade ${dev_python}"
RUN bash -ic "pyenv virtualenv ${py37} ${py37venv} && pyenv activate ${py37venv} && pip install --upgrade ${dev_python}"
RUN bash -ic "pyenv virtualenv ${py38} ${py38venv} && pyenv activate ${py38venv} && pip install --upgrade ${dev_python}"
RUN printf "pyenv activate ${py38venv}\n" >> ~/.bashrc

# nvm
#USER ${adminuser}
#RUN printf "\n# nvm" >> ~/.bashrc
#RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh | bash
#RUN bash -ic "nvm install lts/dubnium && nvm install lts/erbium && nvm install node && nvm alias default node"
#RUN printf "export PATH=node_modules/.bin:\$PATH\nnvm use default\n\n" >> ~/.bashrc

# yarn
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
# RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# RUN sudo apt-get update && sudo apt-get install --no-install-recommends yarn

# cleanup
RUN sudo rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
JosephJeffs commented 4 years ago

During my testing I was not able to build from source and get working using the node:x base images. I switched to ubuntu:20.04 base image and loaded the version of node I needed on top of it and it worked.

You may want to update the readme.md to indicate the proper supported version of Ubuntu.

Thank you for your help.

PaulWieland commented 3 years ago

@bsrdjan I just ran into this as well and it's because all of the official node docker images are using slightly older versions of libstdc++6. Using ubuntu:latest is not ideal because of the resulting image size plus I want to use the official node docker image.

I haven't found an easy way out of this yet...

GLIBCXX_3.4.25 is what's available in node:buster-slim and that seems to be the latest version available from node. node-rfc wants GLIBCXX_3.4.26.

Is it possible for you to release node-rfc compiled against GLIBCXX_3.4.25 instead of .26 so we can use the official image from node?