程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

The python c++ linker automatically extracts the Lib file names of different versions under the directory when inputting

編輯:Python

demand

stay C++ When installing and configuring third-party libraries , It is necessary to distinguish when entering the linker debug Version of lib and release Version of lib, But some large libraries ( for instance OpenCV) Inside lib It's a lot of , Copying and pasting file names one by one is too troublesome , And there is a difference between the two versions d Letter , Easy to see . So I wrote a little script , Automatic extraction lib Under the table of contents debug Version and release Version of lib file name , Write to two txt in , Then, when configuring, directly copy the whole txt Just input the file name in the linker .


Code

import os
def Extract_lib(path):
release = open("release_lib.txt", 'w')
debug = open("debug_lib.txt", 'w')
for file in os.listdir(path):
if file[-5:] == 'd.lib':
debug.write(file)
debug.write('\n')
elif file[-4:] == '.lib':
release.write(file)
release.write('\n')
debug.close()
release.close()
if __name__ == '__main__':
path = r"D:\Program Files (x86)\OPenCV\x64\vc16\lib"
Extract_lib(path)

effect

With OpenCV 4.5.5 As an example of , Enter its lib Catalog :

debug_lib.txt Content

opencv_aruco455d.lib
opencv_barcode455d.lib
opencv_bgsegm455d.lib
opencv_bioinspired455d.lib
opencv_calib3d455d.lib
opencv_ccalib455d.lib
opencv_core455d.lib
opencv_cudaarithm455d.lib
opencv_cudabgsegm455d.lib
opencv_cudacodec455d.lib
opencv_cudafeatures2d455d.lib
opencv_cudafilters455d.lib
opencv_cudaimgproc455d.lib
opencv_cudalegacy455d.lib
opencv_cudaobjdetect455d.lib
opencv_cudaoptflow455d.lib
opencv_cudastereo455d.lib
opencv_cudawarping455d.lib
opencv_cudev455d.lib
opencv_datasets455d.lib
opencv_dnn455d.lib
opencv_dnn_objdetect455d.lib
opencv_dnn_superres455d.lib
opencv_dpm455d.lib
opencv_face455d.lib
opencv_features2d455d.lib
opencv_flann455d.lib
opencv_fuzzy455d.lib
opencv_gapi455d.lib
opencv_hfs455d.lib
opencv_highgui455d.lib
opencv_imgcodecs455d.lib
opencv_imgproc455d.lib
opencv_img_hash455d.lib
opencv_intensity_transform455d.lib
opencv_line_descriptor455d.lib
opencv_mcc455d.lib
opencv_ml455d.lib
opencv_objdetect455d.lib
opencv_optflow455d.lib
opencv_phase_unwrapping455d.lib
opencv_photo455d.lib
opencv_plot455d.lib
opencv_quality455d.lib
opencv_rapid455d.lib
opencv_reg455d.lib
opencv_rgbd455d.lib
opencv_saliency455d.lib
opencv_shape455d.lib
opencv_stereo455d.lib
opencv_stitching455d.lib
opencv_structured_light455d.lib
opencv_superres455d.lib
opencv_surface_matching455d.lib
opencv_text455d.lib
opencv_tracking455d.lib
opencv_video455d.lib
opencv_videoio455d.lib
opencv_videostab455d.lib
opencv_wechat_qrcode455d.lib
opencv_world455d.lib
opencv_xfeatures2d455d.lib
opencv_ximgproc455d.lib
opencv_xobjdetect455d.lib
opencv_xphoto455d.lib

release_lib.txt Content

opencv_aruco455.lib
opencv_barcode455.lib
opencv_bgsegm455.lib
opencv_bioinspired455.lib
opencv_calib3d455.lib
opencv_ccalib455.lib
opencv_core455.lib
opencv_cudaarithm455.lib
opencv_cudabgsegm455.lib
opencv_cudacodec455.lib
opencv_cudafeatures2d455.lib
opencv_cudafilters455.lib
opencv_cudaimgproc455.lib
opencv_cudalegacy455.lib
opencv_cudaobjdetect455.lib
opencv_cudaoptflow455.lib
opencv_cudastereo455.lib
opencv_cudawarping455.lib
opencv_cudev455.lib
opencv_datasets455.lib
opencv_dnn455.lib
opencv_dnn_objdetect455.lib
opencv_dnn_superres455.lib
opencv_dpm455.lib
opencv_face455.lib
opencv_features2d455.lib
opencv_flann455.lib
opencv_fuzzy455.lib
opencv_gapi455.lib
opencv_hfs455.lib
opencv_highgui455.lib
opencv_imgcodecs455.lib
opencv_imgproc455.lib
opencv_img_hash455.lib
opencv_intensity_transform455.lib
opencv_line_descriptor455.lib
opencv_mcc455.lib
opencv_ml455.lib
opencv_objdetect455.lib
opencv_optflow455.lib
opencv_phase_unwrapping455.lib
opencv_photo455.lib
opencv_plot455.lib
opencv_quality455.lib
opencv_rapid455.lib
opencv_reg455.lib
opencv_rgbd455.lib
opencv_saliency455.lib
opencv_shape455.lib
opencv_stereo455.lib
opencv_stitching455.lib
opencv_structured_light455.lib
opencv_superres455.lib
opencv_surface_matching455.lib
opencv_text455.lib
opencv_tracking455.lib
opencv_video455.lib
opencv_videoio455.lib
opencv_videostab455.lib
opencv_wechat_qrcode455.lib
opencv_world455.lib
opencv_xfeatures2d455.lib
opencv_ximgproc455.lib
opencv_xobjdetect455.lib
opencv_xphoto455.lib


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved