Skip to content
⌘ NSIS Forum Archive

LibraryLocal deprecated

17 posts

TrifonovS#

LibraryLocal deprecated

Hi!
Since I use the latest version of NSIS I get a lot of warnings that LibraryLocal is deprecated and !getdllversion should be used instead. All works as before, but these warnings are annoying and I want to fix them. I tried to find some information how LibraryLocal should be replaced by !getdllversions, but there is no enough information. !getdllversion is good described in the documentation of NSIS, but I can't find enough information for LibraryLocal. So my question is, can I get a short example how to replace one with the other?
Anders#
LibraryLocal is a helper application that extracts version information from PE files. It is/was used by Library.nsh when you install/register certain COM, TLB or OCX files (Appendix B in the documentation).

Are you using Library.nsh? Do you have LIBRARY_USELIBRARYLOCALHELPER defined anywhere? Without it I don't think the latest NSIS 3 version will use LibraryLocal anywhere by default but you could be using a 3rd-party header that uses it perhaps?

An outdated Library.nsh file could also cause this.
TrifonovS#
I'm using a macro InstallLib that uses internally another macro __InstallLib_Helper_GetVersion that calls LibraryLocal.exe. I use this macro to install DLLs. I found it long time ago and it always worked. To be honest, I even don't understand it. It looks quite complicated. Probably now this can be programmed much simpler, but I'm afraid to change my script that was good tested and with proven quality during the years. So is there an easy solution to replace only this call of LibraryLocal.exe inside of the macro __InstallLib_Helper_GetVersion?
Anders#
Does your __InstallLib_Helper_GetVersion macro start with "!ifdef LIBRARY_USELIBRARYLOCALHELPER" ?
TrifonovS#
No. Here is the macro:
### Get library version
!macro __InstallLib_Helper_GetVersion TYPE FILE
  !tempfile LIBRARY_TEMP_NSH
  !ifdef NSIS_WIN32_MAKENSIS
    !execute '"${NSISDIR}\Bin\LibraryLocal.exe" "${TYPE}" "${FILE}" "${LIBRARY_TEMP_NSH}"'
  !else
    !execute 'LibraryLocal "${TYPE}" "${FILE}" "${LIBRARY_TEMP_NSH}"'
    !if ${TYPE} == 'T'
      !warning "LibraryLocal currently supports TypeLibs version detection on Windows only"
    !endif
  !endif
  !include "${LIBRARY_TEMP_NSH}"
  !delfile "${LIBRARY_TEMP_NSH}"
  !undef LIBRARY_TEMP_NSH
!macroend 
Anders#
Then there is something wrong with your installation! Try re-installing v3. You have a new LibraryLocal.exe but a old Library.nsh somehow.
TrifonovS#
I reinstalled NSIS V3 (first uninstalled the existing version and checked that there is nothing left). But the result is the same. I also searched my HDD for Library.nsh, but the only file that was found is in Program Files/NSIS/Includes.
Anders#
I don't know what to tell you, both LibraryLocal.exe and Library.nsh changed in SVN r6913 and NSIS v3.03 was released some time after that change.

Just looking at nsis-3.03-setup.exe that I just downloaded in 7-zip I can confirm that it contains the correct Library.nsh.
TrifonovS#
Hi Anders!
Actually you said enough according to the information that I provided to you. I found the problem. The answer is somewhere in this discussion, but unfortunately I couldn't figure it out immediately. Many years ago (>10 years) I made a small extension in the InstallLib macro. It was required to update DLLs with the same version that are already installed. Therefore I modified the script and added a define LIBRARY_VERSION_UPDATEWHENEQUAL that enables this behavior. I copied all the code of the InstallLib macro in my own file and I stopped using Library.nsh to avoid problems with the new versions. Then I completely forgot for this... until now... So it is exactly as you said - I'm using an old version of Library.nsh (not directly, but a code from it). I tried to use again the original Library.nsh and there are no more warnings. But the question now is - can I install DLLs with the same version without my modifications? If I can do this, I will remove my own code and I will not have such problems in the future.
Anders#
Why would it ever make sense to update when the version has not changed? Do you not trust the version number? Or is it because you want to force re-registration?
TrifonovS#
During the development, my colleagues don't change the version of the dlls on every commit, but just when they decide that there is something new in principle. Meantime, when we build the installation (automatically via build server) some newer dlls are not installed, because the version is not changed (but they are actually newer). Of course, this leads to problems with the software after the installation, therefore I got a requirement to reinstall also the dlls with the same versions. It was not my decision.
Anders#
I don't have time to deal with this right now but I would probably accept a simple patch, here or on the SF tracker.
TrifonovS#
I don't know if my patch is completely correct, but it worked so many years (probably not tested in any conditions). I made it in macro InstallLib. The original code is:

      GetDLLVersion $R4 $R2 $R3
      !undef LIBRARY_VERSION_HIGH
      !undef LIBRARY_VERSION_LOW
      !ifndef INSTALLLIB_LIBTYPE_TLB & INSTALLLIB_LIBTYPE_REGDLLTLB
        IntCmpU $R0 $R2 0 "installlib.register_${INSTALLLIB_UNIQUE}" "installlib.upgrade_${INSTALLLIB_UNIQUE}"
        IntCmpU $R1 $R3 "installlib.register_${INSTALLLIB_UNIQUE}" "installlib.register_${INSTALLLIB_UNIQUE}" \
          "installlib.upgrade_${INSTALLLIB_UNIQUE}"
      !else
... 
and I made the following modification:

      GetDLLVersion $R4 $R2 $R3
      !undef LIBRARY_VERSION_HIGH
      !undef LIBRARY_VERSION_LOW
      !ifndef INSTALLLIB_LIBTYPE_TLB & INSTALLLIB_LIBTYPE_REGDLLTLB
        IntCmpU $R0 $R2 0 "installlib.register_${INSTALLLIB_UNIQUE}" "installlib.upgrade_${INSTALLLIB_UNIQUE}"
        !ifdef LIBRARY_VERSION_UPDATEWHENEQUAL
          IntCmpU $R1 $R3 "installlib.upgrade_${INSTALLLIB_UNIQUE}" "installlib.register_${INSTALLLIB_UNIQUE}" \
            "installlib.upgrade_${INSTALLLIB_UNIQUE}"
        !else
          IntCmpU $R1 $R3 "installlib.register_${INSTALLLIB_UNIQUE}" "installlib.register_${INSTALLLIB_UNIQUE}" \
            "installlib.upgrade_${INSTALLLIB_UNIQUE}"
        !endif
  
      !else
... 
The define LIBRARY_VERSION_UPDATEWHENEQUAL enables the modification.
Anders#
That does not seem correct to me, the version is a 64-bit number and you are only checking 32 of them in a different way.
TrifonovS#
Yes, you are right. As I said, I solved my problem many years ago. Still works for my needs. But I prefer an universal solution and I want to discard my special fix.
Anders#
Try this. (Removed attachment, it's included in v3.04 now).

I named the option define LIBRARY_INSTALL_EQUAL_VERSION
TrifonovS#
It looks that it works as it is expected, but I made some very fast tests. I completely removed my specific version of InstallLib and not I use the new Library.nsh file in all my installers. Soon or later the installers will be tested and I will report if I see problems.