Question about what Static Libraries are...


 
Thread Tools Search this Thread
Top Forums Programming Question about what Static Libraries are...
# 1  
Old 12-19-2010
Question about what Static Libraries are...

im used to windows dll which gets loaded at runtime, are static libraries the same? the ones i link with -l on gcc?

i mean, if my app used libpng for example, and i compiled it to a single ELF executable and took it to another pc that have no libpng on it, will it work? or it will complain about missing lib?

thanks....
# 2  
Old 12-19-2010
No. shared libraries are like dll's. The -l<name> thing links first against an .so (shared library), then against a static library. You can overcome that by linking --static.

Static libraries are used when the system is in an unknown state - /sbin/sh is the shell linked staticly so it can run without any external library. The other use for static linking is the case when you have written a custom library, and you want your code to run on machines that have stdc but may not have your library. Then you link that library staticly.
And you do not have to worry about it.
# 3  
Old 12-19-2010
Quote:
Originally Posted by JonhyM
im used to windows dll which gets loaded at runtime, are static libraries the same? the ones i link with -l on gcc?

i mean, if my app used libpng for example, and i compiled it to a single ELF executable and took it to another pc that have no libpng on it, will it work? or it will complain about missing lib?
It will complain about missing libraries.

You can ldd /path/to/executable to see what dynamic libraries they're using or trying to use.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Even the Static cURL Library Isn't Static

I'm writing a program which uses curl to be run on Linux PCs which will be used by a number of different users. I cannot make the users all install curl on their individual machines, so I have tried to link curl in statically, rather than using libcurl.so. I downloaded the source and created a... (8 Replies)
Discussion started by: BrandonShw
8 Replies

2. Linux

Could static library include static library?

I have some static library(libxxx.a libyyy.a). And I want to generate my library(libzzz.a), libzzz.a will use libxxx.a and libyyy.a I wan't my application only use libzzz.a, (means libzzz.a had include libxxx.a, libyyy.a), how can I do that? Thank you. example: I have zzz.c. I do ... (4 Replies)
Discussion started by: freemagic
4 Replies

3. IP Networking

I need HELP to Set up Coyote Linux router with 1 static IP & 64 internal static IP

hello, i need help on setting my coyote linux, i've working on this for last 5 days, can't get it to work. I've been posting this message to coyote forum, and other linux forum, but haven't get any answer yet. Hope someone here can help me...... please see my attached picture first. ... (0 Replies)
Discussion started by: dlwoaud
0 Replies

4. Programming

I want to know some c libraries

I'm a rookie to C and i'm looking for some libraries to learn,something likes the C++ STL or Boost ,does any1 can tell me some of them?Thanks a lot:) Eric (3 Replies)
Discussion started by: homeboy
3 Replies

5. Shell Programming and Scripting

How to use two different libraries?

Hello, I need to use two different libraries like /usr/local/bin/expect and /usr/bin/ksh at the same script. Is it possible? (4 Replies)
Discussion started by: fozay
4 Replies

6. Programming

Static libraries and fork()

Hi, Let's say there's an application compiled with a static library. So, if the application forks processes, then the static library is copied, also? Or the static library codes are shared between the processes of the application? Thanks in advance. (2 Replies)
Discussion started by: xyzt
2 Replies

7. Red Hat

Rebuilding C++ Libraries to save Linux install (purely academic question)

The crisis is over. I am just doing postmortem on how we handled it. So this is just an exercise in academics. We have a mission critical system running on RED Hat Linux. It is a turnkey system "managed 100% by the vendor". I put this is quotes because we had an event last night that... (0 Replies)
Discussion started by: Skyybugg
0 Replies

8. AIX

Static Routes question

I added a static route through smit using: Communications applications and Services ==> TCIP/IP ==> Further Configuration ==> Static Routes ==> Add a Static Route ==> Route Type of host Filled in Destination Address, Default Gateway Address and Network Interface of en0. This... (2 Replies)
Discussion started by: jyoung
2 Replies

9. UNIX for Advanced & Expert Users

static and shared libraries

can someone explain whether my understanding is correct lets suppose we have a program that uses library x. if x is static then the code of x will be part of our program, so if we're going to have 5 executables of our program, then each executable will have x as part of it. Also, x does not... (2 Replies)
Discussion started by: JamesByars
2 Replies

10. Programming

Static objects in libraries

Hi! I have the following problem with C++ programs on Unix: There is a binary executable program called, e.g. Main. It is dynamically linked with two shared libraries: Shared1 and Shared2. Both of these libraries, in turn, are statically linked with a static library called Static. This static... (0 Replies)
Discussion started by: maestro@altiris
0 Replies
Login or Register to Ask a Question