57

You can do this with ldd command: NAME ldd - print shared library dependencies SYNOPSIS ldd [OPTION]... FILE... DESCRIPTION ldd prints the shared libraries required by each program or shared library specified on the command line. .... Example: $ ldd /bin/ls linux-vdso.so.1 => (0x00007fff87ffe000) libselinux....


56

For the current session you can export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib or to make the change permanent you can add /usr/local/lib to /etc/ld.so.conf (or something it includes) and run ldconfig as root. If you're still having problems, running ldd [executable name] will show you the libraries it's trying to find, and which ones can't be found.


51

NOTE: I'm going to assume that your machine has a memory mapping unit (MMU). There is a Linux version (µClinux) that doesn't require an MMU, and this answer doesn't apply there. What is an MMU? It's hardware—part of the processor and/or memory controller. Understanding shared library linking doesn't require you to understand exactly how an MMU works, just ...


48

A .a file is a static library, while a .so file is a shared object (dynamic) library similar to a DLL on Windows. There's some detailed information about the differences between the two on this page.


39

You probably shouldn't do this, but you can. Kusalananda's answer is better for the task at hand and explains the issue. Since you did ask specifically how to use any library calls inside the terminal, though, here's a few ways... The Tiny C Compiler (tcc) supports a -run flag that lets you (in effect) interpret C code by writing a small program, so you can ...


38

Ah yes this is a very confusing part if you've dealt with Unixes for any length of time. There is a standard that most Unixes "try" to follow called FHS - Filesystem Hierarchy Standard. Given I primarily use Red Hat based distros I'm most familiar with their take on FHS for Fedora, CentOS, and RHEL Linux distros. But I've used Debian & BSD based distros ...


38

readelf -d $executable | grep 'NEEDED' Can be used if you can't run the executable, e.g. if it was cross compiled, or if you don't trust it: In the usual case, ldd invokes the standard dynamic linker (see ld.so(8)) with the LD_TRACE_LOADED_OBJECTS environment variable set to 1, which causes the linker to display the library dependencies. Be ...


35

If you've already run ldconfig after building the library, keep reading. If not, read aboout ldconfig first. /usr/local/lib might not be in the library path that ldconfig uses. You can just do this: ldconfig /usr/local/lib And the stuff should be added to the linker cache, but it is probably better to add the path properly. Make sure you have a /etc/ld....


34

The version info in not explicitly stored in an ELF file. What you have in there is the name of the library, the soname, which includes the major version. The full version is usually stored as a part of the library file name. If you have library, say libtest.so, then you usually have: libtest.so.1.0.1 - The library file itself, containing the full version ...


32

Under HP-UX, shared libraries are mapped into memory using mmap(), and all memory pages in the system have protection bits which are coupled with the kernel and processor hardware's memory page protection mechanisms. In order to execute the contents of any page of memory on the system, that page must have PROT_EXEC set - a useful feature to prevent data ...


29

The apropos command is useful in many ways, but it does give you a lot of "junk" too. Most of the things that you list are C library routines (this is what section 3 of the manual is for), which you can not use directly from the shell. To use them, you would have to write C program that calls them. This falls outside of the range of topics covered by this ...


28

But why does it not do the same until it finds the expected version rather than accepting the first instance of library irrespective of its version? It does, as far as it’s aware. zlib.so.1.2.7 and zlib.so.1.2.8 both have an soname of zlib.so.1, so your alpha and bravo binaries say they need zlib.so.1. The dynamic loader loads the first matching library it ...


27

As a follow on, a .a file is an "ar" archive. Not unlike a tar archive, it stores .o or object files, allowing them to be pulled out of the archive, and linked into a program, among other things. You could use ar to store other files if you wanted. You can get a listing of the members of an ar file with the -t parameter, for instance: ar -t /usr/lib/libc.a ...


26

In the latest versions of gcc compiler require that libraries follow the object or source files. So to compile this it should be: gcc pthread_sample.c -lpthread Normally though pthread code is compiled this way: gcc -pthread pthread_sample.c


26

libssl1.0.2 and libssl1.0.0 are different packages, providing incompatible libraries; that’s why you can’t satisfy a libssl1.0.0 dependency using libssl1.0.2. To satisfy your package’s requirements, I’d suggest adding the Debian 8 repositories to your configuration, since Debian 8 is still supported (so if necessary you’ll get security updates). To do so, ...


24

Since you can log in, nothing major is broken; presumably your shell’s startup scripts add ~/lib to LD_LIBRARY_PATH, and that, along with the bad libraries in ~/lib, is what causes the issues you’re seeing. To fix this, run unset LD_LIBRARY_PATH This will allow you to run rm, vim etc. to remove the troublesome libraries and edit your startup scripts if ...


24

The problem is that you have put a copy of glibc into your ~/lib directory, and that library is incompatible with the system you've uploaded it to. The library is being referenced as ~/lib is specified in $LD_LIBRARY_PATH. To temporarily fix this, simply unset LD_LIBRARY_PATH - this will work as unset is a shell built-in. You will then be able to run your ...


20

You can temporarily substitute a different library for this particular execution. In Linux, the environment variable LD_LIBRARY_PATH is a colon-separated set of directories where libraries should be searched for first, before the standard set of directories; this is useful when debugging a new library or using a nonstandard library for special purposes. The ...


20

Non-executable shared objects work fine, but libraries marked executable may also be runnable as standalone programs. So, what's the point of setting this x? None, unless you want them to emit version or other info Must all library packagers do that? No What will happen if I dlopen() a shared library that has 0644 permissions? You'll get a new ...


19

You don't need to. Add the directory to /etc/ld.so.conf or a new file in /etc/ld.so.conf.d/, depending on distro. After that, you must run (at least on Redhat) ldconfig as root. As a word of caution, you need to be careful which libraries you add to the system shared library path (via the environment, ld.so.conf, or putting in /usr/local/lib). In ...


19

You don't have to copy anything anywhere. You should add the atlas libraries to the list of locations ld will search. In directory /etc/ld.so.conf.d you can add the file atlas-lib.conf. This file should contain the directory of libatlas.so.3gf, which is /usr/lib/atlas-base. You can do this by running echo "/usr/lib/atlas-base" | sudo tee /etc/ld.so.conf....


19

You can use: ldconfig -p | grep libavfilter If there is no output library is not installed. I am not sure if this is 100% reliable. At least in man page of ldconfig for option -p: Print the lists of directories and candidate libraries stored in the current cache.


17

The usual dynamic linker on Linux uses a cache to find its libraries. The cache is stored in /etc/ld.so.cache, and is updated by ldconfig which looks on the paths it’s given in /etc/ld.so.conf (and nowadays typically files in /etc/ld.so.conf.d). So there is no default value for LD_LIBRARY_PATH, default library lookup doesn’t need it at all. If ...


16

Write a wrapper script that sets the LD_LIBRARY_PATH environment variable. This is the pendant of PATH for shared libraries. The system search path is always searched after the directories listed in $LD_LIBRARY_PATH. See the dynamic linker manual for reference. #!/bin/sh export LD_LIBRARY_PATH=~/opt/openssl-1.0.1/lib exec /path/to/a.out "$@" Or, for a one-...


16

Debian and Ubuntu are moving to a new multiarch implementation (spec). Among other things, this involves moving arch-specific libraries into /usr/lib/<triplet>, dropping the limitations of lib32 and lib64 (where will the new x32 ABI go? where do qemulated binaries live? etc.) as well as extending the package manager to handle mixed-architecture ...


16

Conceptually, a library function is part of your process. At run-time, your executable code and the code of any libraries (such as libc.so) it depends on, get linked into a single process. So, when you call a function in such a library, it executes as part of your process, with the same resources and privileges. It's the same idea as calling a function you ...


15

It sounds like you're looking for Audacity which is a cross-platform open source audio editor. One of its features is to allow you to generate tones. It's a multi-track audio editor, so you can easily create a stereo tone. Under the Generate menu, you're able to create Sine, Sawtooth, and Square waveform tones of arbitrary frequency, amplitude, and length ...


15

I wouldn't do this for just strlen(), but it is a useful trick for trying out C code sometimes. user@host:~$ gdb gdb (gdb) start Temporary breakpoint 1, ... in main () (gdb) print strlen("foobar") $1 = 6 Here gdb is the GNU debugger, and it would normally take a program name to debug after it. Because we have none, this example gives it itself to debug. ...


15

If on a GNU system, try running your application with: LD_DEBUG=libs your-application See LD_DEBUG=help for more options or man ld.so.


14

You have not said which OS you are using so I am going to assume Linux and will use Debian as an example. The quick answer to your question is no as far as I know. This might be a useful workaround though: ldd your_prog | awk '{print $1}' | sed 's/\..*//' | while read n; do echo "----- $n ----"; apt-cache search ^$n; done This will parse the ldd output ...


Only top voted, non community-wiki answers of a minimum length are eligible