ldd MyExecutable | grep libc
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007eff56bd0000)
This executable requires glibc version 2.25 from Ubuntu 18.04. How can I overwrite it do ask for glibc 2.23, which is the one present on ubuntu 16.04?
I'm aware of possible problems, but how can I do it?
To understand why your binary requires GLIBC_2.25, read this answer.
To understand how you can build a binary which requires older GLIBC version, start here.
Related
Ubuntu 20.04.1 LTS
64-bit
3.36.3 Gnome
Intel core-i7-975H
31.2GiB Memory
1.6 TB Disk Space
Had my flu vaccine
COVID-19: Neg, but I'm boring and don't go anywhere anyway...
I've tried a few fixes, including this one:
Message "Unable to run arm-none-eabi-gdb: cannot find libncurses.so.5"
But no love. I still continue to receive the same error. I'm trying to flash a softdevice using Arduino IDE v1.8.13. GDB version here:
arm-none-eabi-gdb --version
libncurses versions here:
dpkg -l 'ncurses' | grep '^ii'
I do not know what else to try or check. Would someone have any thoughts on what further to check?
#MarkPlotnick - I ran ls -ld $(dpkg -S libncurses.so.5), the result:
ls -ld $(dpkg -S libncurses.so.5)
Then I checked specifically if libncurses5:i386 was installed by trying to install it and it shows the that:
libncurses5:i386 is already the newest version (6.2-0ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I tried one more time a little differently:
sudo apt-get -y install libc6:i386 libstdc++6:i386 libncurses5:i386 libudev1:i386
Then libudev1:i386 was the only package to install. But if I try to find the file:
~$ locate libncurses5:i386
Then I get five file in this location:
/var/lib/dpkg/info/libncurses5:i386.list
/var/lib/dpkg/info/libncurses5:i386.md5sums
/var/lib/dpkg/info/libncurses5:i386.shlibs
/var/lib/dpkg/info/libncurses5:i386.symbols
/var/lib/dpkg/info/libncurses5:i386.triggers
It's like Schödinger File...
First of all, since you are running a 64 bit version of Ubuntu, you should verify you installed the Linux 64 bit version of the Arduino IDE v1.18.13. If this is not the case, this may explain why installing i386 packages did not fix your problem - If you did not, I would strongly suggest to remove the Linux 32 bit version, and install the Linux 64 bit version instead.
This verification can be done by executing the following command:
file ~/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb
You should see something like:
/home/user/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.8, stripped
The important information here would be ELF 64-bit LSB executable.
The 64 bit version of libncurses.so.5 is of course missing:
ldd ~/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb
linux-vdso.so.1 (0x00007ffccf1ed000)
libncurses.so.5 => not found
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f68fa317000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f68fa125000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f68fa11f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f68fa482000)
It can be installed using the following command:
sudo apt-get install libncurses5
After running sudo ldconfig:
ldd ~/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb
linux-vdso.so.1 (0x00007ffcc41f5000)
libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007f890c00d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f890bebe000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f890bccc000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f890bcc6000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f890bc98000)
/lib64/ld-linux-x86-64.so.2 (0x00007f890c04f000)
Your GDB should now be functional:
~/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb -tui
Note that the same kind of issues may happen with the GNU Arm Embedded Toolchain as well on Ubuntu 20.04.1. It can be fixed by installing the missing packages:
sudo apt-get install libtinfo5 libncursesw5 libpython2.7
I am searching for the implementation of localtime() function in time.h. I see that different platforms have different locations for source of c library. I wanted to know the location in Ubuntu 14.04? If by default source is not included in OS, please let me know how to download source or online location of the source.
Thanks.
Check which binary your system uses as libc implementation.
To do so compile a minimal C program and run ldd on it:
ldd a.out
You might get something like this:
linux-vdso.so.1 => (0x00007fff429c6000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f21cdcb7000)
/lib64/ld-linux-x86-64.so.2 (0x00007f21ce05e000)
From this you can pull the info libc is proided by libc6.so.6.
Check which package provides this binary.
Search the package providing the file found under 1.:
dpkg -S libc.so.6
You might get:
libc6-i386: /lib32/libc.so.6
libc6:amd64: /lib/x86_64-linux-gnu/libc.so.6
The above output tells you, that there are two packages providing the file. Here it's the 32 bit and 64 bit implementation.
Decide which one you want and do apt-get source this package's sources.
Assuming the package would be libc6, do
apt-get source libc6
and find thre source in a directory inside the current directory.
When I compile readline into my directory /mypath as instructed (./configure --prefix=/mypath; make; make install) I get the following unresolved symbols in it:
ldd -r /mypath/lib/libreadline.so.6.2
linux-vdso.so.1 => (0x00007ffffb186000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f450c62f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f450cc07000)
undefined symbol: UP (/mypath/lib/libreadline.so.6.2)
undefined symbol: PC (/mypath/lib/libreadline.so.6.2)
undefined symbol: BC (/mypath/lib/libreadline.so.6.2)
When I read the readme-file of readline, this seems to be a feature and not a bug:
`--with-curses'
This tells readline that it can find the termcap library functions
(tgetent, et al.) in the curses library, rather than a separate
termcap library. Readline uses the termcap functions, but does not
link with the termcap or curses library itself, allowing applications
which link with readline the to choose an appropriate library.
This option tells readline to link the example programs with the
curses library rather than libtermcap.
I tried it of course with --with-curses but that did not change anything, which is not surprising because it seems to be a setting that only affects some testing programs in readline.
My distribution (debian) however has a readline without undefined symbols, so it is clearly possible to do.
How to create a readline library without unresolved symbols?
Edit:
I have compiled and installed ncurses into the same directory and I have also tried to configure readline with CFLAGS=" -Wl,-rpath=/mypath" and --enable-static, without success.
Those symbols are defined by libncurses, I think. You can probably confirm this like this:
env LD_PRELOAD=/usr/lib/libncurses.so ldd -r /mypath/lib/libreadline.so.6.2
(I think ldd takes preloads into account when checking symbols, but it may not.)
The build script used by Arch Linux is here. It looks like the trick is to use:
make SHLIB_LIBS=/mypath/libncurses.so
There's also some other adjustments to the -rpath options in a build file, so you might need that also.
The make install step is installing the shared library in some directory, often /usr/local/lib/
You need to make the dynamic loader ld.so(8) aware of that. I would suggest add once /usr/local/lib/ into your /etc/ld.so.conf file then running ldconfig after each installation of new shared libraries inside it. See ldconfig(8), ldd(1)
You could also specify some -Wl,-rpath when linking programs with your version of libreadline.so
And when building a shared library you can link it to other shared libraries. On my Debian the system libreadline is linked to libtinfo:
% ldd /lib/x86_64-linux-gnu/libreadline.so.6
linux-vdso.so.1 (0x00007ffffccf3000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f45cffcc000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f45cfc23000)
/lib64/ld-linux-x86-64.so.2 (0x00007f45d046c000)
You may want to study the source package of your readline6, since it contains the patches to the building procedure.
BTW, my Debian has a libtinfo5 package (obtained with dpkg -S /lib/x86_64-linux-gnu/libtinfo.so.5)
I know how to check the GNU C Library on my x86 workstation, but now I would like to know which GLIBC version is using my cross toolchain for ARM (I didn't build the toolchain). I cant test the libc.so.6 file of my toolchain's $PATH library in my x86 workstation.
Is there some way to know the glibc version without compile a test program and testing in my embedded system? Furthermore, how can I know which PATH library is using by default the GNU linker of my toolchain?
You can use ldd --version command to check version, like in GLIBC version.
You should call ldd from your toolchain:
/full/path/to/your/toolchain/lib/usr/bin/ldd --version.
In the gcc manual it is given that "The C standard library itself
is stored in ‘/usr/lib/libc.a’". I have gcc installed, but could not find libc.a at the said location. Curious to know where is it located.
I find many .so files in /usr/lib location. What are those?
If you are looking for libc.a:
$ gcc --print-file-name=libc.a
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libc.a
A few things:
gcc and glibc are two different things. gcc is the compiler, glibc are the runtime libraries. Pretty much everything needs glibc to run.
.a files are static libraries, .so means shared object and is the Linux equivalent of a DLL
Most things DON'T link against libc.a, they link against libc.so
Hope that clears it up for you. As for the location, it's almost certainly going to be in /usr/lib/libc.a and / or /usr/lib/libc.so. Like I said, the .so one is the more common.
If you are on RPM based Linux (Red Hat/CentOS/Fedora/SUSE) then you would get the location of the installed glibc with
rpm -ql glibc and rpm -ql glibc-devel .
locate libc.a would get you the location. And to see from where it comes do:
rpm -qf /usr/lib/libc.a
Here is what rpm -qi has to tell about these packages
glibc-devel:
The glibc-devel package contains the object files necessary
for developing programs which use the standard C libraries (which are
used by nearly all programs). If you are developing programs which
will use the standard C libraries, your system needs to have these
standard object files available in order to create the
executables.
Install glibc-devel if you are going to develop programs which will
use the standard C libraries
glibc:
The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and
memory, as well as to make upgrading easier, common system code is
kept in one place and shared between programs. This particular package
contains the most important sets of shared libraries: the standard C
library and the standard math library. Without these two libraries, a
Linux system will not function.
You need to install package for static libraries separately:
glibc-static.i686
On centos 5.8
$ ls -l /usr/lib/libc.a
-rw-r--r-- 1 root root 2442786 Apr 8 2010 /usr/lib/libc.a
$ rpm -qf /usr/lib/libc.a
glibc-devel-2.3.4-2.43.el4_8.3
You also have to have the glibc-devel package install under RedHat distributions.