1

Is there any way you can set the version number of a binary built with g++ on Linux? I know on Windows this is quite easy in the project settings of Visual Studio but can you do it on Linux? I'm using eclipse as my IDE.

jignatius
  • 6,304
  • 2
  • 15
  • 30
  • What's the version number of a binary built? – πάντα ῥεῖ Jun 26 '19 at 20:20
  • I mean the file version number – jignatius Jun 26 '19 at 20:24
  • There's no such thing like a _"file vwrsion number"_ unless you introduce some repository database like SVN or such. – πάντα ῥεῖ Jun 26 '19 at 20:27
  • 1
    Do you mean the `soname` (including version) of a shared library? A generic ELF executable does not contain any standardized "version number" of the executable AFAIK. But, you can embed whatever info you like in a custom ELF header or section, for *your own* use - just don't expect anyone else to pay it any attention. – Jesper Juhl Jun 26 '19 at 20:27
  • 1
    Back in the day, people used the `rcs` versioning system and put strings in each `.c` file, like `static char const rcsid[] = "$Id: f.c,v 5.4 1993/11/09 17:40:15 eggert Exp $";`. These strings could later be extracted with `ident binary` to get a list of all the object files used to build the binary. I think that practise stopped last millennia. – Ted Lyngmo Jun 26 '19 at 20:47

1 Answers1

0

there is no such thing as ELF file version in Linux environment but this answer can help you to make workaround about it Does gcc have any options to add version info in ELF binary file?

zapredelom
  • 1,009
  • 1
  • 11
  • 28
  • Thanks for the info. Seems like a lot of hassle for something small. I think it might be easier if the program outputs the version when you run with a '--version' flag. Ideally I shouldn't have to run the program at all. – jignatius Jun 26 '19 at 20:54