Changing LD_LIBRARY_PATH for "loading shared library libstdc++.so.6:"

In my project I need to use django-libsass..
Libraries(django-libsass and libsass) have installed correctly.

Everything works fine on locally but not when deploying to web server.

On the production server the app is dockerized. The project is build successfully with requirements and their dependencies.

When I try to test libsass on the prod. server from the Django shell,

>>> import sass
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/sass.py", line 26, in <module>
    import _sass
ImportError: Error loading shared library libstdc++.so.6: No such file or directory (needed by /usr/local/lib/python3.8/site-packages/_sass.abi3.so)

In the gcc gnu online docs, there is a such info about that error,

This doesn’t mean that the shared library isn’t installed, only that the dynamic linker can’t find it. When a dynamically-linked executable is run the linker finds and loads the required shared libraries by searching a pre-configured list of directories. If the directory where you’ve installed libstdc++ is not in this list then the libraries won’t be found.

To fix this is I tried to use the LD_LIBRARY_PATH environment variable.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64

But, python/django app does not notify that environment variable when I simply add it.

My questions:

If setting LD_LIBRARY_PATH is the solution, how can I achieve this?
or Is there any other proper solution to fix that error?

You have verified that that specific version of that file is in your docker container at that location?

And you’re setting that environment variable either in your docker-compose file or on your docker run command?

1 Like

Sorry for replying late. I have now found the suitable time to fix this issue.

I’ve search the files in the docker container and I noticed that the required file is not find.

/ $ find . -type f -name libstdc++.so.6.0*

Then I’ve checked my Dockerfile and I realised that I added required libraries the line of;

RUN apk add --update --no-cache --virtual .tmp-build-deps \
...other dependencies ... g++  libstdc++

There is virtual tag . Then, I try to add these libraries without using virtual tag.

RUN apk add --update --no-cache .... g++ libstdc++

Problem is solved with that change.

I didn’t think the problem would come from that and I focused on the wrong things.

Thanks.