I need to obtain the information on the C-compiler used to build an installed program. I am guessing a rt or a lib can report that, but nothing concrete. Not that the program would be installed in /usr/...
or a similar place, and hence would not have access to the build directory to get the relevant info.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Well behaved programs should understand the --version
argument.
Packaged programs (i.e. those installed with dpkg -i
or apt-get install
of a .deb
package on Debian, etc...) also know their package version and source.
You might try to use strings
on the binary executable. However, such meta-data (about the version of the C compiler used to build the program) might have been stripped (e.g. by the strip
command).
If you are developing the program (i.e. its C source code) and can change it, you might consider adding something like
timestamp.c: Makefile
echo 'const char timestamp[]=' > $@
date +'"built with $(shell $(CC) --version) on %c";' >> $@
yourprogram: $(OBJECTS) timestamp.o
$(LINK.c) $(LDFLAGS) $< -o $@ $(LDLIBES)
$(RM) timestamp.c
in your Makefile
(details could be wrong, but you get the idea)