2

I want to read a library version of dynamic library (.dylib on Mac and .dll on Windows) with Qt method. Say I created several versions of given library over time and now I want to read the version itself. We can add the version to the project, see: add version.

  1. I do know how to read Qt library version: QT_VERSION_STR
  2. I do know how to read the version of my application: QApplication::applicationVersion()

I have the libraries created manually with some versions. Now I want to be able to read from the file (.dylib or .dll) which version was set.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Mateusz
  • 51
  • 5

2 Answers2

0

AFAIK, the VERSION variable in qmake does not actually change anything in the object file, at least not for Windows. (I actually checked the Makefiles to verify it.)

My suggestion is that you bake the version number into the object file itself and provide a callable method to retrieve it.

jwernerny
  • 6,978
  • 2
  • 31
  • 32
  • Thanks for the suggestion, jwernerny. Since this is the library which is actually the part of the project, and it is dependent on it, I do not have the methods which loads the library. I use the methods which are part of the library. The point is that the may be updated partially and the other part becomes outdated. This is something I would like to determine. – Mateusz Sep 30 '13 at 12:21
0

Its been some time since I posted it but since @Liviu asks I will try answer it myself.
First of all I did not find a satisfying Qt-based solution.

For sake of analysis, the Qt routines can be used in order to provide secured usage I would suggest to create new dynamic libraries with security checks with help of macro QT_VERSION_CHECK and example to prevent proceeding with older Qt versions:

#include <QtGlobal>`
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QtWidgets>
#else
#include <QtGui>
#endif

However, in case the library is already created and possibly deployed on some local machine this kind of solution cannot be applied. In that case one would need some sort of dependency parser. I.e. on Linux machine it could be the ldd functionality utilization, see SO answer. In osx the otool parsing tool shall to be used. The parsed info shall contain the Qt version used during library file creation (.dll, .dylib or .so file).

Community
  • 1
  • 1
Mateusz
  • 51
  • 5