Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Sorry but I got to ask...
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
EvilN
n00b
n00b


Joined: 13 Feb 2003
Posts: 47
Location: Stockholm, Sweden

PostPosted: Thu Jun 19, 2003 11:13 am    Post subject: Sorry but I got to ask... Reply with quote

Major n00b question.

I see a lot of programs that can be compiled both dynamic and static or are pre compiled dynamic or static.
I have no idea what the diefference is so if anybody could give me a really brief explanation I'd be greatful.

An example:
http://www.iglooftp.com/unix/download.html
_________________
Juniper Networks Certified Internet Associate
JNCIA-M #0090
Back to top
View user's profile Send private message
skunkworx
Guru
Guru


Joined: 02 Feb 2003
Posts: 420
Location: Planet Houston

PostPosted: Thu Jun 19, 2003 11:46 am    Post subject: Answer Reply with quote

Assuming they aren't referring to something else entirely, static and dynamic refer to how the program references standard function libraries, such as the input/output routines used by almost all programs written in C and C++. Static programs have these libraries compiled directly into the program. Dynamic programs attach themselves to dynamic link libraries (DLL files) stored somewhere on your computer. Static programs are easier to transport, because all the code they need is right there in the program. Dynamic programs, on the other hand, are smaller and more versatile, since the DLLs can be updated without recompiling the program.

---Kris Kelley
Back to top
View user's profile Send private message
miwjpa
n00b
n00b


Joined: 16 Mar 2003
Posts: 21

PostPosted: Thu Jun 19, 2003 11:51 am    Post subject: static and dynamic linking Reply with quote

If you're referring to static and dynamic linking here's my explanation:

Generally all programs call machine code in other libraries. A library in this case is a file containing a collection of object code files (often .o files). A library can be either static (foo.a) or shared (dynamic) (foo.so). If you use a static library it will be joined/linked with your code when you compile it. If you use a shared/dynamic library only a small part of the library is linked/joined with your compiled program. The shared library is then dynamically loaded on execution of your program.

Advantages with static libraries: Your program comes as a complete unit with respect to the static library. Your don't have to depend on the user having a copy of the library installed. You know what code your program uses.
Disadvantages: Larger size of your compiled program (mainly on disk). If you need to change something in the static library you need to recompile and distribute your program as a whole.

Advantages with shared libraries: The library code can be shared between different programs which means your program is smaller on disk. Shared libraries often share memory while loaded which means less memory usage. Easier to update.
Disadvantages: You must make sure the user uses a version of your library which supports whatever you need in it.

If you compare with the Windows platform, shared/dynamic libraries are the DLL files and static libraries use the LIB extension.
Back to top
View user's profile Send private message
wallace1819
Apprentice
Apprentice


Joined: 17 Aug 2002
Posts: 195
Location: VT

PostPosted: Thu Jun 19, 2003 12:38 pm    Post subject: security Reply with quote

there is also a security issue. If a vuln is found in a library, you may need to recompile each application you staticly compiled with that library. This requires you to keep track of what app you compiled staticly with what libraries.

wallace
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum