获取已安装程序的编译信息 [英] Get compilation info of an installed program

查看:77
本文介绍了获取已安装程序的编译信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取有关用于生成已安装程序的C编译器的信息。我猜测rt或lib可以报告该信息,但是没有具体的信息。并不是说该程序将安装在 / usr /...或类似的位置,因此将无权访问构建目录来获取相关信息。

解决方案

表现良好的程序应理解-version 参数。 / p>

打包程序(即使用 dpkg -i apt-get install安装的程序 .deb 软件包中的code>也知道其软件包版本和来源。



您可能会尝试在二进制可执行文件上使用 strings 。但是,此类元数据(大约是用于构建程序的C编译器的版本)可能已被剥离(例如,通过 strip 命令)。



如果您正在开发程序(即其C源代码)并且可以对其进行更改,则可以考虑添加类似的内容

  timestamp.c:Makefile 
echo'const char timestamp [] ='> $ @
日期+在%c上使用$(shell $(CC)--version)构建;’>> $ @

您的程序:$(OBJECTS)timestamp.o
$(LINK.c)$(LDFLAGS)$< -o $ @ $(LDLIBES)
$(RM)timestamp.c

Makefile (细节可能是错误的,但您会明白的)


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.

解决方案

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)

这篇关于获取已安装程序的编译信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆