LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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, 10: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, 10:16 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Have you searched the forums? These questions have been answered often.
 
Old 01-21-2007, 05: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, 05: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, 11: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, 11: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, 12:21 PM   #7
paulsm4
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 12:23 PM.
 
1 members found this post helpful.
Old 04-09-2011, 07: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 04:40 AM.
 
1 members found this post helpful.
Old 04-10-2011, 01:34 AM   #9
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
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, 06:46 AM   #10
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,272

Rep: Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663
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, 04: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 05:06 AM.
 
Old 09-04-2011, 09:36 PM   #12
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:58 PM
Dynamic link libraries eshwar_ind Programming 1 05-10-2004 12:02 AM
Static vs Dynamic Big Al Linux - Networking 2 12-08-2003 04:10 PM
NS with static or dynamic IP cijunet Linux - Networking 3 05-09-2003 12:04 AM
linux dynamic libraries aizkorri Programming 4 10-09-2002 04:26 AM


All times are GMT -5. The time now is 11:00 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration