LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-18-2007, 09:05 AM   #1
nesta
Member
 
Registered: Aug 2006
Posts: 100

Rep: Reputation: 15
static and dynamic libraries


hi folks,
i want to know what is the differences between:
1)cross-compiling and our normal compiling
2)static and dynamic linking
3)static and shared libraries
 
Old 01-18-2007, 09:16 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Have you searched the forums? These questions have been answered often.
 
Old 01-21-2007, 04:21 AM   #3
nesta
Member
 
Registered: Aug 2006
Posts: 100

Original Poster
Rep: Reputation: 15
hi all,
i have take your advice and read about static linking and dynamic linking but i still have one question:

can the static library be loaded during the run-time ?
or is it only loaded during the compile time ?

thanks in advance.
 
Old 01-21-2007, 04:37 AM   #4
The Headacher
Member
 
Registered: Jan 2007
Distribution: Vector Linux
Posts: 90

Rep: Reputation: 15
I'm not sure how this is in other languages, but in C both static and shared libraries can be loaded dynamically.

Here's a "program library Howto" that I am using to get a better understanding of libraries at the moment: http://www.dwheeler.com/program-library/
 
Old 01-21-2007, 10:25 AM   #5
nesta
Member
 
Registered: Aug 2006
Posts: 100

Original Poster
Rep: Reputation: 15
dear the headacher
can u send the link again , as it does not work?
thanks in advance.
 
Old 01-21-2007, 10:46 AM   #6
The Headacher
Member
 
Registered: Jan 2007
Distribution: Vector Linux
Posts: 90

Rep: Reputation: 15
Hmm.. It was there earlier today, but it seems down now. It's also hosted here: http://tldp.org/HOWTO/Program-Library-HOWTO/index.html
 
Old 01-21-2007, 11:21 AM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
can the static library be loaded during the run-time ?
or is it only loaded during the compile time ?
Static libraries (generally ".a" files on *nix, and ".lib" files on DOS/Windows) are included into the exe at link time (not compile time). They become part of the executable code.

Shared libraries, on the other hand, are brought in as-needed into the running process at execution time. This can be done automatically by the OS at program startup, or programmatically by the process itself as it executes.

Cross compiling is completely different - it's running a compiler on one machine (like an x86 running Linux) to compile objects and build executables for a complete different machine (like an embedded system).

The link cited above it a good one:
http://tldp.org/HOWTO/Program-Library-HOWTO/index.html

Here are a couple of others that might help:

http://en.wikipedia.org/wiki/Shared_library
http://yolinux.com/TUTORIALS/Library...ndDynamic.html
http://docs.python.org/ext/dynamic-linking.html

Last edited by paulsm4; 01-21-2007 at 11:23 AM.
 
1 members found this post helpful.
Old 04-09-2011, 06:28 PM   #8
Marko-M
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Rep: Reputation: 2
If anyone stumbles here, I've wrote three howtos on my site about C/C++ library programming on Linux (creating and using shared and static libraries).

Here are the links:

C/C++ library programming on Linux – Part one: Static libraries

C/C++ library programming on Linux – Part two: Dynamic libraries

C/C++ library programming on Linux – Part three: Dynamic libraries using POSIX API

Good luck!

Last edited by Marko-M; 07-25-2011 at 03:40 AM.
 
1 members found this post helpful.
Old 04-10-2011, 12:34 AM   #9
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by nesta View Post
...
can the static library be loaded during the run-time ?
or is it only loaded during the compile time ?
...
How about first looking up definitions on the web ?

I.e. try to enter

static library

into whatever web search engine and read the matches.
 
Old 04-10-2011, 05:46 AM   #10
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Sergei Steshenko, post # 9 :

I'd guess post 8 and the five identical posts from @Marko-M has
an advertisement purpose.

Two times text complaining about "blocked advertisement"
( I use Adblock++ ) is actually paying more attention than
the very short "howto".

( The @ nesta post you answered is four years old.)

..
 
0 members found this post helpful.
Old 07-25-2011, 03:52 AM   #11
Marko-M
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Rep: Reputation: 2
Quote:
Originally Posted by knudfl View Post
Sergei Steshenko, post # 9 :

I'd guess post 8 and the five identical posts from @Marko-M has
an advertisement purpose.

Two times text complaining about "blocked advertisement"
( I use Adblock++ ) is actually paying more attention than
the very short "howto".

( The @ nesta post you answered is four years old.)

..
Hi! I wasn't posting links to virus or adult content. I gave three links to my articles I've spent days writing with purpose of helping Linux grow. With money I've came up from ads on my site during last few years you wouldn't buy a decent hamburger so If I wanted to make money I would certainly write about some other more spread OS then Linux. We all love Linux but costs money, time and passion to help it spread. Go out there and write some useful Linux articles or open source software, I've done both

Last edited by Marko-M; 07-25-2011 at 04:06 AM.
 
Old 09-04-2011, 08:36 PM   #12
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Marko-M, it's clear that your intentions at LQ are solely to promote your own site. You have a total post count of 6 and 5 of which are identical posts to your brief how-to articles. To gain respect around here, I suggest your answer some recent questions, but I'm pretty sure all you care about are the links back to your site.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic IP to Static Temujin_12 *BSD 2 06-10-2005 04:58 PM
Dynamic link libraries eshwar_ind Programming 1 05-09-2004 11:02 PM
Static vs Dynamic Big Al Linux - Networking 2 12-08-2003 03:10 PM
NS with static or dynamic IP cijunet Linux - Networking 3 05-08-2003 11:04 PM
linux dynamic libraries aizkorri Programming 4 10-09-2002 03:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration