使用Linux靜態庫
查看靜態庫.a文件包含的內容用下面的命令解壓:
ar x libgdal.a
然後就可以查看文件了:
ls
adler32.o cpl_recode.o dted_create.o gdalpamrasterband.o geo_write.o nitfimage.o tif_fax3sm.o tif_tile.o
compress.o cpl_recode_stub.o dted_ptstream.o gdalproxydataset.o gt_citation.o nitfwritejpeg_12.o tif_float.o tif_version.o
cpl_atomic_ops.o cplstringlist.o gdalallregister.o gdalproxypool.o gt_overview.o nitfwritejpeg.o tif_flush.o tif_vsi.o
cpl_base64.o cpl_string.o gdalallvalidmaskband.o gdalrasterband.o gt_wkt_srs.o overview.o tif_getimage.o tifvsi.o
cpl_conv.o cplstring.o gdalcolortable.o gdalrasterblock.o infback.o rasterio.o tif_jpeg_12.o tif_warning.o
cpl_csv.o cpl_strtod.o gdaldataset.o gdal_rat.o inffast.o rpftocfile.o tif_jpeg.o tif_write.o
cpl_error.o cpl_time.o gdaldefaultasync.o gdal_rpcimdio.o inflate.o tif_aux.o tif_luv.o tif_zip.o
cpl_findfile.o cpl_vsil.o gdaldefaultoverviews.o geo_extra.o inftrees.o tif_close.o tif_lzma.o trees.o
cpl_getexecpath.o cpl_vsil_readahead_reader.o gdaldllmain.o geo_free.o jpgdataset_12.o tif_codec.o tif_lzw.o uncompr.o
cplgetsymbol.o cpl_vsil_sparsefile.o gdaldrivermanager.o geo_get.o jpgdataset.o tif_color.o tif_next.o vsidataio.o
cpl_hash_set.o cpl_vsil_stdin.o gdaldriver.o geo_names.o libgdal.a tif_compress.o tif_ojpeg.o xtiff.o
cpl_http.o cpl_vsil_subfile.o gdalmajorobject.o geo_new.o libgdal.so tif_dirinfo.o tif_open.o zutil.o
cplkeywordparser.o cpl_vsil_unix_stdio_64.o gdal_misc.o geo_normalize.o libogr.a tif_dir.o tif_packbits.o
cpl_list.o cpl_vsi_mem.o gdalmultidomainmetadata.o geo_print.o mgrs.o tif_dirread.o tif_pixarlog.o
cpl_minixml.o cpl_vsisimple.o gdalnodatamaskband.o geo_set.o nitfaridpcm.o tif_dirwrite.o tif_predict.o
cpl_multiproc.o cpl_xml_validate.o gdalnodatavaluesmaskband.o geo_simpletags.o nitfbilevel.o tif_dumpmode.o tif_read.o
cpl_path.o crc32.o gdalopeninfo.o geotiff.o nitfdataset.o tif_error.o tif_strip.o
cpl_progress.o deflate.o gdalpamdataset.o geo_tiffp.o nitfdes.o tif_extension.o tif_swab.o
cpl_recode_iconv.o dted_api.o gdalpamproxydb.o geotiff_proj4.o nitffile.o tif_fax3.o tif_thunder.o
自己打包靜態庫,還是用ar命令:
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文件一起打包:
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,解釋如下:
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
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(符號),用下面的命令:
nm -g libNAME.a
會打印每個包含的文件,以及文件內的symbol。
相關鏈接:
Linux 動態庫的創建和使用 http://www.linuxidc.com/Linux/2013-03/81084.htm
Linux 靜態庫的創建和使用 http://www.linuxidc.com/Linux/2013-03/81083.htm
Linux靜態庫和動態庫的編寫和使用 http://www.linuxidc.com/Linux/2013-09/89868.htm
Linux下動態庫和靜態庫的生成和使用 http://www.linuxidc.com/Linux/2012-07/66850.htm
關於Linux靜態庫和動態庫的分析 http://www.linuxidc.com/Linux/2012-04/59072.htm
Linux 下創建靜態庫和動態庫 http://www.linuxidc.com/Linux/2012-04/58354.htm