我可以确定哪些编译器/链接器标志用于创建仅二进制共享库吗? [英] Can I determine which compiler/linker flags where used to create a binary-only shared library?
问题描述
我想知道是否有办法找出哪个 g ++
编译器/链接器标志用于创建仅包含二进制文件的库。
例如,可能有第三方共享库(只有.h / .so文件存在)。
所以我认为它会在编译和链接我自己的应用程序时(使用仅使用二进制的第三方库),使用相同的g ++标志是一个好主意。
具体而言,我要求编译器标志,如
哪些链接器标志已被使用:
- -fpic或-fPIC
- -fexceptions
- -pthreads
等等。
没有系统的方法来做到这一点。您可以查看库是否链接到libpthread,作为是否使用 -pthreads
的指示。对于PIC /非PIC代码,您可能需要尝试这个。优化级别,调整和其他方面将很难确定。
I am wondering if there is a way to find out which g++
compiler/linker flags where used in creating a binary-only library.
For example there might be a 3rd party shared library (only .h/.so files are there).
So I think it would be a good idea to use the same g++ flags when compiling and linking my own application (that is using the binary-only 3rd party library).
Specifically I am asking for compiler flags like
- -fno-inline
- -pthreads
- -mtune=arch
- -O2
and also it would be of interest which linker flags have been used:
- -fpic or -fPIC
- -fexceptions
- -pthreads
and so on.
There is no systematic way of doing this. You can look if the library is linked to libpthread as an indication of whether -pthreads
was used. For PIC/non-PIC code, you may want to try this. Optimization level, tuning and others will be much harder to determine.
这篇关于我可以确定哪些编译器/链接器标志用于创建仅二进制共享库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!