1. Are shared libraries and dynamic libraries the same exact thing?
windows just labels them as .dll
, and linux labels them as .so
?
2. If a shared libarary has a ton of functions that a program uses, when are those functions loaded into memory?
At the start of the program? when the particular function is actually called?
3. If I make a library like this:
#ifndef SHARED_H
#define SHARED_H
#include <iostream>
#include <string>
namespace shared
{
void Function1(void);
void Function2(void);
void Function3(void);
void Function4(void);
void Function5(void);
void Function6(void);
...
void Function99(void);
void Function100(void);
...
}
//assume none of these functions call each other
#endif
and my client program only calls one of those functions, will their be performance decrease because of all the other extra functions not used?
Not worried about compilation time.. just the actual running time
4. Is question 3's scenario different if I use a class:
#ifndef SHARED_H
#define SHARED_H
#include <iostream>
#include <string>
class Shared
{
public:
void Function1(void);
void Function2(void);
void Function3(void);
void Function4(void);
void Function5(void);
void Function6(void);
...
void Function99(void);
void Function100(void);
...
private:
protected:
};
//assume none of these functions call each other
#endif
5. I'm use to making a lot of objects(.o files), and then linking them together to make my executable.
would it be better to turn all of my objects(which are usually classes) into a .so file AND THEN link them together?
I understand that the executable will rely on the .so file, unlike the first approach where the objects can just be deleted after compilation, but what is the recommendation on this?
6. I'm a bit in the dark about the difference between -fPIC and -fpic
I've heard that -fPIC will always work and -fpic is target-dependent.
What does target dependent mean? If the library is always going to be compiled and used on the same machine, am I safe to use -fpic?
some of these questions may be trivial, but I want to be certain about the things I've read so far. I appreciate any and all responses
*If relevant: using gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)