Code: |
strings -a /path/to/binary-file | grep "GCC:" | sort -u |
Here is a dirt-simple scripted version of the pipeline.
which-gcc: |
#!/bin/bash if [ -z "$1" ] ; then echo "Usage: which-gcc file" echo "Determines GCC version(s) used to build file" exit fi strings -a $1 | grep "GCC:" | sort -u |
Here are some examples from my system:
Code: |
$ which-gcc /bin/bash GCC: (GNU) 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9) |
Code: |
$ which-gcc `which vuescan` GCC: (GNU) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) |
Code: |
$ which-gcc /opt/google-earth/googleearth-bin GCC: (GNU) 3.4.5 20050809 (prerelease) (Ubuntu 3.4.4-6ubuntu8) GCC: (GNU) 4.0.2 |
Code: |
$ which-gcc /usr/bin/ooffice2 |
ooffice2 is not a GCC executable, thus no output. (It's a Bourne shell script. Reader exercise: produce a useful message when the file argument is not a GCC-created executable. )