简体   繁体   English

静态库-调试还是发布?

[英]Static library - debug or release?

I come from Windows and I generated a C++ static library (libMyLib.a) with gcc. 我来自Windows,使用gcc生成了C ++静态库(libMyLib.a)。

In Windows you can actually generate a debug static library (.lib) with debugging information and unoptimized; 在Windows中,您实际上可以生成带有调试信息且未优化的调试静态库(.lib)。 then you can also generate a release static library (.lib) without debugging information and meant to be linked in the final product statically. 那么您还可以生成一个发布静态库(.lib),而无需调试信息,并且可以在最终产品中进行静态链接。

I did 我做了

$ objdump --syms libMyLib.a | grep "debug"

and got a bunch of lines like 并有一堆线像

0000000000002ea0 l     F .text  00000000000001fc _ZN12_GLOBAL__N_121debugMyFunction2Ejllj

since there's the 'debug' suffix I believe this static library is a debug one with debugging information embedded into it. 因为有'debug'后缀,所以我相信这个静态库是一个调试库,其中嵌入了调试信息。 I'm not sure why this is extremely smaller compared to the Windows one (300 MB for Windows while only 13 MB for Linux).. I suspect some debugging information is missing. 我不确定为什么它与Windows操作系统相比要小得多(Windows操作系统只有300 MB,Linux操作系统只有13 MB)。我怀疑缺少一些调试信息。

I have two questions at this point: 我现在有两个问题:

  1. Am I right in stating that the static .a library is a debug one containing all the necessary debug information? 我是否正确地说静态.a库是包含所有必需调试信息的调试库?
  2. Are release static libraries generated in linux (ready to be linked in the final product, static library, no debugging info) at all? 是否在linux中生成了发布静态库(已准备好在最终产品中链接,静态库,没有调试信息)? And if they are, how can I make one? 如果是的话,我该怎么做?

A binary file, wether it is a static lib, a dynamic lib, an executable program or anything else, may contain or not debug information. 二进制文件,无论是静态库,动态库,可执行程序还是其他任何文件,都可能包含或不包含调试信息。 It's your compilation option that determine wether debug information should be generated or not. 由您的编译选项确定是否应生成调试信息。 For example, for gcc, see: https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html 例如,对于gcc,请参阅: https : //gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM