ldconfig error: is not a symbolic link when using Linux loader
I ran into this issue with the Oracle 11R2 client. Not sure if the Oracle installer did this or someone did it here before I arrived. It was not 64-bit vs 32-bit, all was 64-bit.
The error was that libexpat.so.1
was not a symbolic link.
It turned out that there were two identical files, libexpat.so.1.5.2
and libexpat.so.1
. Removing the offending file and making it a symlink to the 1.5.2 version caused the error to go away.
Makes sense that you'd want the well-known name to be a symlink to the current version. If you do this, it's less likely that you'll end up with a stale library.
How to control shared library version issue on Linux?
Yes, create a symlink named libXXX.so.0
pointing to libXXX.so.0.0.0
.
If you want people to be able to construct programs that are linked against this library then also create a symlink named libXXX.so
pointing to libXXX.so.0
.
The libXXX.so.0 symlink will be used by the program loader, because that's the soname that the program will be looking for.
The libXXX.so
symlink will be used by the linker when it is building a program, because by historical convention that's how the linker works.
Besides, what if I update the library to libXXX.so.0.0.1?
Then you remake the libXXX.so.0
symlink so that it points to libXXX.so.0.0.1
. Nothing else needs to change. Since the libXXX.so
symlink points to libXXX.so.0
it will automatically also point to the new library.
how to update the symlink?
If you're installing the new library by using some packaging system (RPM, ...) then use whatever feature the packaging system provides for managing symlinks. If you're just using a script or a Makefile stanza then simply rm -f
the old symlink and ln -s
the new one.
Linux - SO file not found
Check your LD_LIBRARY_PATH environment variable... One of the directories on the path should point to the location of your log4cpp.so
file; also the linux command ldd
is handy for determining which shared object libraries are being used in your executable. The syntax is ldd <executable>
.
Linux Program can't find Shared Library at run-time
Symlinks on libraries work fine, as long as the final target they trace to exists and is accessible.
You have built a dynamically-linked executable, that wishes to be linked against libid3-3.8.so.3 at execution time. This was likely linked during the build phase with something like -L/path/to/libid3/directory -lid3
.
You have a few options to make libid3
available, in generally decreasing order of preference (since you didn't mention where the file was, I can only be general):
- Create a symlink to
libid3*
in a directory listed in/etc/ld.so.conf
(or/lib
or/usr/lib
) - Copy
libid3*
to a directory listed in/etc/ld.so.conf
(or/lib
or/usr/lib
) (defaults) - Add the directory containing
libid3*
to/etc/ld.so.conf
- Set
LD_LIBRARY_PATH=/directory/path/to/libid3*
before running your id3v2 executable. - Recompile
id3v2
statically. (It will work, but don't bother.)
After any of the first 3, rerun ldconfig
so the linker cache is updated. (You can then run ldconfig -v
to verify it's resolvable.)
Note those aren't steps, they're options. You only need to do 1 of them.
Glad you updated the title. #include
directives have nothing to do with linking.
Linux regex error: unmatched slash and curly braces
The error is related to the unescaped }
. You have tried to use an interval quantifier in a POSIX BRE pattern, but you have not escaped both the {
and }
.
However, it seems you may just use
grep 'BAT.*90$' file
See the online grep
demo
The BAT.*90$
POSIX BRE pattern here matches
BAT
- aBAT
substring.*
- any 0+ chars90$
-90
at the end of the string (line here asgrep
operates on a line by line basis by default)
As no -o
option was used, grep
will output the whole lines that contain this pattern, no need for the ^.*
part.
Docker Alpine executable binary not found even if in PATH
On Alpine Linux, the not found
error is a typical symptom of dynamic link failure. It is indeed a rather confusing error by musl's ldd
linker.
Most of the world Linux software is linked against glibc, the GNU libc library (libc provides the standard C library and POSIX API). Most Linux distributions are based on glibc. OTOH, Alpine Linux is based on the musl libc library, which is a minimal implementation and strictly POSIX compliant. Executables built on glibc distributions depend on /lib/x86_64-linux-gnu/libc.so.6
, for example, which is not available on Alpine (unless, they are statically linked).
Except for this dependency, it's important to note that while musl attempts to maintain glibc compatibility to some extent, it is far from being fully compatible, and complex software that's built against glibc won't work with musl-libc, so simply symlinking /lib/ld-musl-x86_64.so.1
to the glibc path isn't likely going to work.
Generally, there are several ways for running glibc binaries on Alpine:
- Install one the glibc compatibility packages, libc6-compat or gcompat:
# apk add gcompat
apk add libc6-compat
Both packages provide a light weight glibc compatibility layer which may be suitable for running simple glibc applications.libc6-compat
implements glibc compatibility APIs and provides symlinks to glibc shared libraries such as libm.so
, libpthread.so
and libcrypt.so
. The gcompat
package is based on Adelie Linux gcompat project and does the same but provides a single library libgcompat.so
. Both libraries install loader stubs. Depdending on the application, one of them may work while the other won't, so it's good to try both.
- Install proper glibc on Alpine, for providing all glibc methods and functionalities. There are glibc builds available for Alpine, which should be installed in the following procedure (example):
# Source: https://github.com/anapsix/docker-alpine-java
ENV GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc
ENV GLIBC_VERSION=2.30-r0
RUN set -ex && \
apk --update add libstdc++ curl ca-certificates && \
for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION}; \
do curl -sSL ${GLIBC_REPO}/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \
apk add --allow-untrusted /tmp/*.apk && \
rm -v /tmp/*.apk && \
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib
Use statically linked executables. Static executables don't carry dynamic dependencies and could run on any Linux.
Alternatively, the software may be built from source on Alpine.
For LibreDWG, let's first verify the issue:
/usr/local/bin # ./dwg2dxf
/bin/sh: ./dwg2dxf: not found
/usr/local/bin
/usr/local/bin # ldd ./dwg2dxf
/lib64/ld-linux-x86-64.so.2 (0x7fd375538000)
libredwg.so.0 => /usr/local/lib/libredwg.so.0 (0x7fd3744db000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fd375538000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fd375538000)
Error relocating /usr/local/lib/libredwg.so.0: __strcat_chk: symbol not found
Error relocating /usr/local/lib/libredwg.so.0: __snprintf_chk: symbol not found
Error relocating /usr/local/lib/libredwg.so.0: __memcpy_chk: symbol not found
Error relocating /usr/local/lib/libredwg.so.0: __stpcpy_chk: symbol not found
Error relocating /usr/local/lib/libredwg.so.0: __strcpy_chk: symbol not found
Error relocating /usr/local/lib/libredwg.so.0: __printf_chk: symbol not found
Error relocating /usr/local/lib/libredwg.so.0: __fprintf_chk: symbol not found
Error relocating /usr/local/lib/libredwg.so.0: __strncat_chk: symbol not found
Error relocating /usr/local/lib/libredwg.so.0: __sprintf_chk: symbol not found
Error relocating ./dwg2dxf: __snprintf_chk: symbol not found
Error relocating ./dwg2dxf: __printf_chk: symbol not found
Error relocating ./dwg2dxf: __fprintf_chk: symbol not found
You can see that dwg2dxf
depends on several glibc symbols.
Now, let's follow option 2 for installing glibc:
/usr/src/app # cd /usr/local/bin
/usr/local/bin # ls
dwg2SVG dwg2dxf dwgadd dwgbmp dwgfilter dwggrep dwglayers dwgread dwgrewrite dwgwrite dxf2dwg dxfwrite
/usr/local/bin # ./dwg2dxf
/bin/sh: ./dwg2dxf: not found
/usr/local/bin # export GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc && \
> export GLIBC_VERSION=2.30-r0 && \
> apk --update add libstdc++ curl ca-certificates && \
> for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION}; \
> do curl -sSL ${GLIBC_REPO}/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \
> apk add --allow-untrusted /tmp/*.apk && \
> rm -v /tmp/*.apk && \
> /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/1) Installing curl (7.74.0-r1)
Executing busybox-1.32.1-r3.trigger
OK: 629 MiB in 126 packages
(1/2) Installing glibc (2.30-r0)
(2/2) Installing glibc-bin (2.30-r0)
Executing glibc-bin-2.30-r0.trigger
/usr/glibc-compat/sbin/ldconfig: /usr/local/lib/libredwg.so.0 is not a symbolic link
/usr/glibc-compat/sbin/ldconfig: /usr/glibc-compat/lib/ld-linux-x86-64.so.2 is not a symbolic link
OK: 640 MiB in 128 packages
removed '/tmp/glibc-2.30-r0.apk'
removed '/tmp/glibc-bin-2.30-r0.apk'
/usr/glibc-compat/sbin/ldconfig: /usr/glibc-compat/lib/ld-linux-x86-64.so.2 is not a symbolic link
/usr/glibc-compat/sbin/ldconfig: /usr/local/lib/libredwg.so.0 is not a symbolic link
Voila:
/usr/local/bin # ./dwg2dxf
Usage: dwg2dxf [-v[N]] [--as rNNNN] [-m|--minimal] [-b|--binary] DWGFILES...
Related Topics
Git Sparse-Checkout Ignore Specific File Type
What Is the Recommended Way to Perform Source-Level Debugging of System Library Calls
Rename Part of File Name Based on Exact Match in Contents of Another File
Set Filetype and Comment Key Map with .S File
Printing Variable to Command Line Using Assembly in Linux
How to Wrap Lines Within Columns in Linux
While Do Loop and Variables in a Bash Script
How to Build an App for an Old Linux Distribution, and Avoid the Fatal: Kernel Too Old Error
Have One Folder with Files That Have the Same Name But Different File
Execute Command Line and Return Command Output
Logrotate to Clean Up Date Stamped Files