Click here to Skip to main content
15,885,309 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDifference between Static lib and Dynamic lib Pin
NiceNaidu12-Jul-06 23:22
NiceNaidu12-Jul-06 23:22 
AnswerRe: Difference between Static lib and Dynamic lib Pin
Prakash Nadar13-Jul-06 0:58
Prakash Nadar13-Jul-06 0:58 
GeneralRe: Difference between Static lib and Dynamic lib Pin
Chris Losinger13-Jul-06 3:29
professionalChris Losinger13-Jul-06 3:29 
GeneralRe: Difference between Static lib and Dynamic lib Pin
Prakash Nadar14-Jul-06 4:48
Prakash Nadar14-Jul-06 4:48 
GeneralRe: Difference between Static lib and Dynamic lib Pin
Zac Howland13-Jul-06 4:11
Zac Howland13-Jul-06 4:11 
GeneralRe: Difference between Static lib and Dynamic lib Pin
Prakash Nadar14-Jul-06 4:53
Prakash Nadar14-Jul-06 4:53 
GeneralRe: Difference between Static lib and Dynamic lib Pin
earl14-Jul-06 5:03
earl14-Jul-06 5:03 
AnswerRe: Difference between Static lib and Dynamic lib Pin
Rilhas17-Jul-06 13:16
Rilhas17-Jul-06 13:16 
I assume what you mean is: "by looking at a lib file, can I determine if the executables (or DLL's) that link with it will contain the code that the lib is representing, or will the executable need to load the code from an external DLL?".

You link to a lib file to be able to use code that you are not providing. For example, the "fopen" function needs the "libc.lib" library (or equivalent) to provide you with the code necessary to open a file. You will not provide this code, the "libc.lib" will. Let's call this the "additional code".

However, the way the lib provides the additional code to you can be in 2 diferent ways:

1) It can contain the additional code itself (the set of additional machine instructions that do the actual job that you are needing). In this example, the additional "fopen" code would be contained in the lib, accessing the disk, locking the directory, marking the file as open, etc...

2) It can request the OS to load a DLL from disk and get the additional code from it. In this situation, the lib loads the DLL from disk (usually when the executable loads into memory and before it begins to run) finds the address of the "fopen" function code within it, and provides you with a link to acess this additional code present in the DLL. So, when you call "fopen" you are accessing the lib's "fopen", which is a stub that just links to the location in the DLL where the actual "fopen" code resides and executes it for you.

So, the best indicator that a lib contains the code or not is the size. Small libs (50kb or so) typically contain only names of functions to link to the DLL. Larger libs (500kb or more) usually contain the code itself, and do not rely on external DLL's. These values, of course, are just general guidelines.

The most acurate way I now is for you to produce your executable and then use the dependency walker to determine if it depends on external new DLL's ("new" means "the exe did not need them until I linked with the libs").

Also note that the linker is very smart. If you are not using code from a lib then just linking with it does not mean a DLL will be needed, since the linker will find that out and end up not using its code. To be sure you use it call some of its functions in your program.

I hope this helps,
Rilhas

Questionget the desktop(monitor) width and height using win32 Pin
kk_mfc12-Jul-06 23:19
kk_mfc12-Jul-06 23:19 
AnswerRe: get the desktop(monitor) width and height using win32 Pin
Jonathan [Darka]12-Jul-06 23:23
professionalJonathan [Darka]12-Jul-06 23:23 
GeneralRe: get the desktop(monitor) width and height using win32 Pin
Jonathan [Darka]12-Jul-06 23:29
professionalJonathan [Darka]12-Jul-06 23:29 
AnswerRe: get the desktop(monitor) width and height using win32 Pin
Naveen12-Jul-06 23:24
Naveen12-Jul-06 23:24 
AnswerRe: get the desktop(monitor) width and height using win32 Pin
NiceNaidu12-Jul-06 23:26
NiceNaidu12-Jul-06 23:26 
AnswerRe: get the desktop(monitor) width and height using win32 Pin
Hamid_RT13-Jul-06 0:08
Hamid_RT13-Jul-06 0:08 
GeneralRe: get the desktop(monitor) width and height using win32 Pin
kk_mfc13-Jul-06 0:31
kk_mfc13-Jul-06 0:31 
QuestionCatching Exceptions thrown by a process Pin
Pavan Rao12-Jul-06 22:54
Pavan Rao12-Jul-06 22:54 
AnswerRe: Catching Exceptions thrown by a process Pin
Jonathan [Darka]12-Jul-06 23:04
professionalJonathan [Darka]12-Jul-06 23:04 
AnswerRe: Catching Exceptions thrown by a process Pin
Stephen Hewitt13-Jul-06 1:20
Stephen Hewitt13-Jul-06 1:20 
GeneralRe: Catching Exceptions thrown by a process Pin
Pavan Rao13-Jul-06 18:57
Pavan Rao13-Jul-06 18:57 
GeneralRe: Catching Exceptions thrown by a process Pin
Pavan Rao13-Jul-06 21:27
Pavan Rao13-Jul-06 21:27 
QuestionFindFile in website Pin
includeh1012-Jul-06 22:37
includeh1012-Jul-06 22:37 
AnswerRe: FindFile in website Pin
eusto13-Jul-06 0:50
eusto13-Jul-06 0:50 
GeneralRe: FindFile in website Pin
Hamid_RT13-Jul-06 1:16
Hamid_RT13-Jul-06 1:16 
GeneralRe: FindFile in website Pin
eusto13-Jul-06 3:15
eusto13-Jul-06 3:15 
GeneralRe: FindFile in website Pin
Hamid_RT13-Jul-06 3:24
Hamid_RT13-Jul-06 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.