Search code examples
clinuxgccautotoolslibtool

retrieve lib version generated with autotool


I'm trying to find a way to get the version of my library, compiled with .

I added -version-info 1:1:1 to LD_FLAGS in makefile.am and the output is ok: lib.so.0.1.1

What I need is to retrieve runtime the version of that library and show it on an information panel.

I'm thinking on two different ways to do that:

  1. Use an external file (eg. header) where I can define versions and that make makefile.am able to read version values from it. In this way I can access it form my code also.
  2. A way, different then parsing the filename of library on FS, to retrieve the version set by -version-info option.

Is one of those ideas applicable?


Solution

  • Define LIB_VERSION = 0:1:1

    Use it: -version-info $(LIB_VERSION) and append it to cflags if you want to use it from code: -DVERSION=$(LIB_VERSION)