Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When is a recompile required when a dependent .LIB changes? 1

Status
Not open for further replies.

titanandrews

Programmer
Feb 27, 2003
130
US
Hi All,

I have a question regarding creating a dll and static linking against a dependent .LIB. In what cases does the dll need to be compiled and re-linked for it to function correctly during runtime?
1) If the .LIB has been re-compiled and NOTHING has been changed?
2) If the .LIB has been re-compiled and something HAS changed, for example new functions have been added?
3) If the .LIB has been compiled with a different version than the dll you are trying to create?

I know number 2 is true, but I am not sure about 1 and 3. I know that the MSVS compiler will encrypt a version number and embed it into the .dll and .lib files but what does that really affect?

many many thanks,

B
 
If nothing new has been added in case 1 & 3, what's the point of recompiling?
 
Well... in case 1, suppose you don't have control over this library. So maybe you know if something has changed and maybe not. The point is there is a new version of the library. Is a recompile of my .dll required and if so, why? In case 3, the point of recompiling is upgrading to a new version of the compiler. Does anyone know the answers to these questions? Many Thanks!
 
#1 specifically says that "NOTHING has changed". So recompiling won't do anything for you.

For #3, you can run into trouble by mixing files that were compiled on different compilers/versions since they might use different binary formats.
 
Yeah that makes sense. This may be a different topic, but is a .lib file considered to be changed if that .lib file depends on another one that WAS changed or does this matter at all?
Thanks again for the reply!
 
Thanks for your replies! Can you tell me what is the exact reason that my dll must be re-compiled? Obviously if I run it against the changed dependent library it will fail at runtime. But what is the reason? Is there some library signature, version number, or something that my dll knows about? Or something else?

thanks,
B
 
Let me see if I can get a picture of what you're doing...

[ignore][.lib file] is a dependency of -> [.dll file]
[.dll file] is used by -> [test application][/ignore]

Is the .lib file used anywhere else? Are there more DLLs or exe's in the picture?

What do you mean it fails at runtime? I'm guessing it crashes? Once you compile the .lib file into your DLL, you don't need the .lib file anymore. If your program was working, then started crashing after someone updated the .lib file, there must be some other DLLs that were compiled with the new .lib file that your program is using.

As far as I know, Visual Studio uses the date/time stamp of the file to know if it has been updated, in which case it then re-compiles/links with the new file.
 
[.lib file] is a dependency of -> [.dll file]
[.dll file] is used by -> [test application]"

That is correct.

"Is the .lib file used anywhere else?"
yes, I use the dlls that belong to this .lib file.
"Are there more DLLs or exe's in the picture?"
yes, but not relevant.

"What do you mean it fails at runtime? I'm guessing it crashes?"

Yes it crashes.
"there must be some other DLLs that were compiled with the new .lib file that your program is using."

That is correct.

This is a hypothetical situation, although I did run into these kinds of problems in the past. I'm just trying to figure out exactly how and more importantly why these scenarios play out. In the Java world, you can change class A all day, and as long as you don't remove a method or change it's signature that class B is calling, everything works without having to recompile class B. I know it's not exactly the same as C++ since there is no linking step, but still class A can be considered a library used by other classes.
 
Well to be honest, I don't know exactly why you have problems when mixing different versions of a library in different modules of your program; I just know from experience that you do.

Maybe ArkM or Salem... know a more precise reason why problems like this happen?

All I can tell you is, if one part of your program compiles with a newer library, you should update that library in all the other modules of your program that use the same library.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top