Reputation: 449
When you compile a program using the following command, are you linking against a static or dynamic library?
g++ blink.cpp -o blink -lmraa
Secondly, this library was 'installed' from a PPA using these commands
sudo add-apt-repository ppa:mraa/mraa
sudo apt-get update
sudo apt-get install libmraa1 libmraa-dev mraa-tools python-mraa python3-mraa
How can you tell if the library is static or dynamic?
Upvotes: 0
Views: 772
Reputation: 136495
When you compile a program using the following command, are you linking against a static or dynamic library?
See man ld
:
-l namespec
--library=namespec
Add the archive or object file specified by namespec to the list of files to link. This option may be used any number of times. If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a.
On systems which support shared libraries, ld may also search for files other than libnamespec.a. Specifically, on ELF and SunOS systems, ld will search a directory for a library called libnamespec.so before searching for one called libnamespec.a. (By convention, a ".so" extension indicates a shared library.) Note that this behavior does not apply to :filename, which always specifies a file called filename.
Linux is an ELF system. So, the linker searches for .so
first and then for .a
.
How can you tell if the library is static or dynamic?
It can be both, bust most likely .so
. You need to see what files comprise those packages.
You can also invoke ldd <executable>
on the resulting executable or shared library and see what shared libraries it needs.
Upvotes: 1