Shared libraries are libraries that are loaded by programs when they start. A single shared copy of each library is loaded into physical memory and may be used by multiple processes at the same time. This reduces memory use and improves system performance. This tag should never be used alone.
Questions tagged [shared-libraries]
7905 questions
37
votes
3 answers
Can I use shared library created in C++ in a C program?
I am creating programs using C. However, I require to use a lot of libraries that have API's only for C++. So, is it possible that I can create a shared object in C++ and then access its functionality using C?
The only data I would be passing and…

coolharsh55
- 1,179
- 4
- 12
- 27
36
votes
2 answers
CMake output name for dynamic-loaded library?
I'm trying to write cmake rules to build dynamic-loaded library for python using boost.python on linux. I'd like to use 'foo' for python module name. So, the library must be called foo.so.
But by default, cmake uses standard rules for library…

Anton Kazennikov
- 3,574
- 5
- 30
- 38
35
votes
1 answer
How to build a dylib from several .o in Mac OS X using gcc
I have several .o files and want to bundle them in a .dylib, how can I do that it Mac OS X using gcc? Thank you very much.

Tianyi Cui
- 3,933
- 3
- 21
- 18
34
votes
2 answers
Why is CMake designed so that it removes runtime path when installing
I built my shared library(I use a lib calculating the fibonacci number for example) myself and want to use it in my another c++ project built by CMake
Let's say the shared library and headers located in /path/to/my/lib, the shared library libfib.so…

Alaya
- 3,287
- 4
- 27
- 39
34
votes
3 answers
How can LD_LIBRARY_PATH be changed within CMake?
I have a local shared library which is not in $LD_LIBRARY_PATH.
I want to run my executable, but since it cannot find the shared library in the system folders, it outputs "error while loading shared libraries".
A possible fix for this is to export a…

Daniel Saad
- 385
- 1
- 3
- 9
34
votes
7 answers
libpython2.7.so.1.0: cannot open shared object file: No such file or directory
I have trying to run python script from the terminal but getting the next error message :
ImportError: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
if I run print sys.version I get :
>>> import sys
>>> print…

yehudahs
- 2,488
- 8
- 34
- 54
34
votes
5 answers
What is the difference between LD_LIBRARY_PATH and -L at link time?
I'm having problems with LD_LIBRARY_PATH at link time (this question has nothing to do with run time).
The link line looks like this when I run make (this is a Linux system using g++ version 4.1.x):
g++ a.o b.o c.o -o myapp \
-L/long/path/to/libs/…

Dan
- 5,929
- 6
- 42
- 52
34
votes
10 answers
How to recover after deleting the symbolic link libc.so.6?
In our server the symbolic link to libc.so.6 has been deleted. Now none of the binaries in the system work. To fix this, I tried:
/bin/ln -s /lib/libc-2.11.3.so /lib/libc.so.6
which, as expected, gives me:
/bin/ln: error while loading shared…

perreal
- 94,503
- 21
- 155
- 181
34
votes
1 answer
LD_PRELOAD equivalent for Windows to preload shared libraries
I'm trying to do exactly what LD_PRELOAD does, i.e. preload a shared library or DLL files on Windows to a given program to override certain functions.
Is there a LD_PRELOAD equivalent for Windows?
I don't have any specific functionalities in mind. I…

dm76
- 4,130
- 8
- 35
- 46
34
votes
3 answers
How compatible are different versions of glibc?
Specifically:
Is it assured somehow that all versions of glibc 2.x are binary compatible?
If not, how can I run a binary (game) on my system which has been compiled for a different version? Can I install glibc in a different folder?
My specific…

Aaron Digulla
- 321,842
- 108
- 597
- 820
33
votes
3 answers
Shared Libraries: Windows vs Linux method
I have a quick question about Windows shared libraries (DLLs) vs Linux shared libraries (SOs).
Why is it that when you create a Windows DLL it requires the client program to also link against a static library (.lib file), but applications created in…

QAH
- 4,200
- 13
- 44
- 52
33
votes
3 answers
Linking a shared library against a static library: must the static library be compiled differently than if an application were linking it?
At least on Linux and Solaris, static libraries are really just a bunch of compiled .o's tossed into one big file. When compiling a static library, usually the -fpic flag is ommited, so the generated code is position dependent.
Now say my static…

Joseph Garvin
- 20,727
- 18
- 94
- 165
33
votes
1 answer
undefined reference to symbol even when nm indicates that this symbol is present in the shared library
What could be wrong here? I have the following simple class:
#include "libmnl/libmnl.h"
int main() {
struct mnl_socket *a = mnl_socket_open(12);
}
And after running a simple gcc compile (gcc -lmnl main.c) I get the following…

user389238
- 1,656
- 3
- 19
- 40
32
votes
3 answers
making gcc prefer static libs to shared objects when linking?
When linking against libraries using the -l option (say -lfoo), gcc will prefer a shared object to a static library if both are found (will prefer libfoo.so to libfoo.a). Is there a way to make gcc prefer the static library, if both are found?
The…

Ákos Maróy
- 919
- 2
- 10
- 19
32
votes
2 answers
How to include external library with python wheel package
I want to create package for python that embeds and uses an external library (.so) on Linux using the cffi module.
Is there standard way to include .so file into python package?
The package will be used only internally and won't be published to…

vvladymyrov
- 5,715
- 2
- 32
- 50