Regarding build process.

I have an application that is dependent on a dynamic external library. To compile my application I give include directory of the library . I understand that I need to recompile my application whenever any of the header files in the include directory changes, but if its not a change in the include directory and the dynamic library changes because of some internal code change, do i still need to recompile my application?
By saying dynamic external library you either mean a shared library on UNX or Linux or a DLL on Windows, then probably not.
Thanks Kooth, thats what i thought. But strange thing was it was still working fine even after one of the header files changed. I even tried calling the interface that changed, one of the input parameter was removed. It still was working fine.
learngintocode wrote:
But strange thing was it was still working fine even after one of the header files changed.


This is because C++ is not an scripting language. The .c, .cpp, .h, .hpp files that you see are text files in the most literal sense and the extensions are put there just to keep things organized (open one with notepad if you want proof, *nix guys already know this). Changing any of these files has zero impact on the executable after it is compiled until it is compiled again and the executable is overwritten.
Last edited on
Well I was not referring to header file in my local folder which I used for compiling. I meant the changed .so file was generated with modified header files than the one I used while compiling my application.

I built my application first with libXX.so version 1. Then loaded libXX.so version 2. the version 2 was compiled with modified header files. It still ran fine.

To be sure what is being loaded, run ldd on your executable.
I even tried calling the interface that changed, one of the input parameter was removed. It still was working fine.

That's mere luck. If it's a C library or if the function was exported with C naming convention (extern "C"), then function parameters are not included in the symbol name, so linking will still succeed. However the function will be called with the wrong number of parameters, which results in undefined behavior.
But if it was a C++ library, linking should have failed.
Topic archived. No new replies allowed.