Questions tagged [shared-libraries]

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.

7188 questions
597
votes
8 answers

Difference between static and shared libraries?

What is the difference between static and shared libraries? I use Eclipse and there are several project types including Static Libraries and Shared Libraries? Does one have an advantage over the other?
Mohit Deshpande
  • 48,747
  • 74
  • 187
  • 247
475
votes
5 answers

What are .a and .so files?

I'm currently trying to port a C application to AIX and am getting confused. What are .a and .so files and how are they used when building/running an application?
Dunc
  • 6,777
  • 9
  • 27
  • 35
451
votes
18 answers

When to use dynamic vs. static libraries

When creating a class library in C++, you can choose between dynamic (.dll, .so) and static (.lib, .a) libraries. What is the difference between them and when is it appropriate to use which?
Morten Christiansen
  • 17,568
  • 19
  • 62
  • 91
406
votes
18 answers

Linux error while loading shared libraries: cannot open shared object file: No such file or directory

Program is part of the Xenomai test suite, cross-compiled from Linux PC into Linux+Xenomai ARM toolchain. # echo $LD_LIBRARY_PATH …
zaratustra
  • 6,510
  • 8
  • 32
  • 40
256
votes
1 answer

What's the difference between .so, .la and .a library files?

I know an .so file is a kind of dynamic library (lots of threads can share such libraries so there is no need to have more than one copy of it in memory). But what is the difference between .a and .la? Are these all static libraries? If dynamic libs…
hugemeow
  • 7,177
  • 13
  • 43
  • 59
249
votes
13 answers

How to show all shared libraries used by executables in Linux?

I'd like to know which libraries are used by executables on my system. More specifically, I'd like to rank which libraries are used the most, along with the binaries that use them. How can I do this?
Alan Szlosek
  • 2,861
  • 2
  • 17
  • 12
207
votes
5 answers

How do I view the list of functions a Linux shared library is exporting?

I want to view the exported functions of a shared library on Linux. What command allows me to do this? (On Windows I use the program depends)
ljbade
  • 4,096
  • 3
  • 26
  • 34
187
votes
1 answer

Build .so file from .c file using gcc command line

I'm trying to create a hello world project for Linux dynamic libraries (.so files). So I have a file hello.c: #include void hello() { printf("Hello world!\n"); } How do I create a .so file that exports hello(), using gcc from the…
sashoalm
  • 63,456
  • 96
  • 348
  • 677
175
votes
4 answers

C++ Dynamic Shared Library on Linux

This is a follow-up to Dynamic Shared Library compilation with g++. I'm trying to create a shared class library in C++ on Linux. I'm able to get the library to compile, and I can call some of the (non-class) functions using the tutorials that I…
Bill the Lizard
  • 369,957
  • 201
  • 546
  • 842
174
votes
7 answers

ld cannot find an existing library

I am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar problems with a few other libraries too. I am…
maxpenguin
  • 4,709
  • 6
  • 26
  • 21
161
votes
4 answers

How to create a shared library with cmake?

I have written a library that I used to compile using a self-written Makefile, but now I want to switch to cmake. The tree looks like this (I removed all the irrelevant files): . ├── include │   ├── animation.h │   ├── buffers.h │   ├── ... │   ├──…
Florian M
  • 2,045
  • 3
  • 15
  • 14
154
votes
4 answers

Call Go functions from C

I am trying to create a static object written in Go to interface with a C program (say, a kernel module or something). I have found documentation on calling C functions from Go, but I haven't found much on how to go the other way. What I've found…
beatgammit
  • 18,285
  • 16
  • 79
  • 123
145
votes
9 answers

How do I find out what all symbols are exported from a shared object?

I have a shared object (dll). How do I find out what all symbols are exported from that?
chappar
  • 6,747
  • 12
  • 39
  • 56
137
votes
7 answers

Why can't Python find shared objects that are in directories in sys.path?

I'm trying to import pycurl: $ python -c "import pycurl" Traceback (most recent call last): File "", line 1, in ImportError: libcurl.so.4: cannot open shared object file: No such file or directory Now, libcurl.so.4 is in…
user135171
120
votes
6 answers

Importing from a relative path in Python

I have a folder for my client code, a folder for my server code, and a folder for code that is shared between them Proj/ Client/ Client.py Server/ Server.py Common/ __init__.py Common.py How do I import…
Drew
  • 9,858
  • 10
  • 52
  • 88
1
2 3
99 100