查看静态库.a文件包含的内容

拜拜、爱过 提交于 2020-03-23 13:44:26

查看静态库.a文件包含的内容用下面的命令解压:

 

[plain] view plain copy
 
 print?
  1. ar x libgdal.a  

然后就可以查看文件了:

 

 

[plain] view plain copy
 
 print?
  1. ls  
  2. adler32.o           cpl_recode.o                 dted_create.o               gdalpamrasterband.o  geo_write.o      nitfimage.o         tif_fax3sm.o    tif_tile.o  
  3. compress.o          cpl_recode_stub.o            dted_ptstream.o             gdalproxydataset.o   gt_citation.o    nitfwritejpeg_12.o  tif_float.o     tif_version.o  
  4. cpl_atomic_ops.o    cplstringlist.o              gdalallregister.o           gdalproxypool.o      gt_overview.o    nitfwritejpeg.o     tif_flush.o     tif_vsi.o  
  5. cpl_base64.o        cpl_string.o                 gdalallvalidmaskband.o      gdalrasterband.o     gt_wkt_srs.o     overview.o          tif_getimage.o  tifvsi.o  
  6. cpl_conv.o          cplstring.o                  gdalcolortable.o            gdalrasterblock.o    infback.o        rasterio.o          tif_jpeg_12.o   tif_warning.o  
  7. cpl_csv.o           cpl_strtod.o                 gdaldataset.o               gdal_rat.o           inffast.o        rpftocfile.o        tif_jpeg.o      tif_write.o  
  8. cpl_error.o         cpl_time.o                   gdaldefaultasync.o          gdal_rpcimdio.o      inflate.o        tif_aux.o           tif_luv.o       tif_zip.o  
  9. cpl_findfile.o      cpl_vsil.o                   gdaldefaultoverviews.o      geo_extra.o          inftrees.o       tif_close.o         tif_lzma.o      trees.o  
  10. cpl_getexecpath.o   cpl_vsil_readahead_reader.o  gdaldllmain.o               geo_free.o           jpgdataset_12.o  tif_codec.o         tif_lzw.o       uncompr.o  
  11. cplgetsymbol.o      cpl_vsil_sparsefile.o        gdaldrivermanager.o         geo_get.o            jpgdataset.o     tif_color.o         tif_next.o      vsidataio.o  
  12. cpl_hash_set.o      cpl_vsil_stdin.o             gdaldriver.o                geo_names.o          libgdal.a        tif_compress.o      tif_ojpeg.o     xtiff.o  
  13. cpl_http.o          cpl_vsil_subfile.o           gdalmajorobject.o           geo_new.o            libgdal.so       tif_dirinfo.o       tif_open.o      zutil.o  
  14. cplkeywordparser.o  cpl_vsil_unix_stdio_64.o     gdal_misc.o                 geo_normalize.o      libogr.a         tif_dir.o           tif_packbits.o  
  15. cpl_list.o          cpl_vsi_mem.o                gdalmultidomainmetadata.o   geo_print.o          mgrs.o           tif_dirread.o       tif_pixarlog.o  
  16. cpl_minixml.o       cpl_vsisimple.o              gdalnodatamaskband.o        geo_set.o            nitfaridpcm.o    tif_dirwrite.o      tif_predict.o  
  17. cpl_multiproc.o     cpl_xml_validate.o           gdalnodatavaluesmaskband.o  geo_simpletags.o     nitfbilevel.o    tif_dumpmode.o      tif_read.o  
  18. cpl_path.o          crc32.o                      gdalopeninfo.o              geotiff.o            nitfdataset.o    tif_error.o         tif_strip.o  
  19. cpl_progress.o      deflate.o                    gdalpamdataset.o            geo_tiffp.o          nitfdes.o        tif_extension.o     tif_swab.o  
  20. cpl_recode_iconv.o  dted_api.o                   gdalpamproxydb.o            geotiff_proj4.o      nitffile.o       tif_fax3.o          tif_thunder.o  


自己打包静态库,还是用ar命令:

 

 

[plain] view plain copy
 
 print?
  1. ar -rcs output/linux_debug_x64/libgdal.a build/port/obj/Debug64/*.o build/gcore/obj/Debug64/*.o build/frmts/obj/Debug64/*.o build/ogr/obj/Debug64/*.o  


还可以将.a文件和.o文件一起打包:

 

 

[plain] view plain copy
 
 print?
  1. ar -rcs output/linux_debug_x64/libgdal.a build/port/obj/Debug64/*.o build/gcore/obj/Debug64/*.o build/frmts/obj/Debug64/*.o output/linux_debug_x64/libogr.a  


参数c是创建

 

参数s是添加索引

参数r是将后面的*.o或者*.a文件添加到目标文件中

为了兼容性,可以使用参数f,解释如下:

 

[plain] view plain copy
 
 print?
  1. f   Truncate names in the archive.  GNU ar will normally permit file names of any length.  This will cause it to create archives which are not compatible with the  
  2.            native ar program on some systems.  If this is a concern, the f modifier may be used to truncate file names when putting them in the archive.  

 

 

查看.a文件的symbols(符号),用下面的命令:

 

[plain] view plain copy
 
 print?
  1. nm -g libNAME.a  

会打印每个包含的文件,以及文件内的symbol。

http://blog.csdn.net/csfreebird/article/details/11741075

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!