Windows函数转发器
作者:互联网
最近MSYS2升级后出现了一个bug,libxml264-157.dll被升级成了libxml264-159.dll,但是ffplay还依赖libxml264-157.dll,本来打算直接复制一个libxml264-159.dll重命名为libxml264-157.dll,但是发现libxml264-157.dll里面有一个函数x264_encoder_open_157在libxml264-159.dll变成了x264_encoder_open_159,这样程序就会找不到x264_encoder_open_157这个函数,最后我通过函数转发器解决了这个问题。函数转发器的声明如下:
// Function forwarders to functions in DllWork #pragma comment(linker, "/export:SomeFunc=DllWork.SomeOtherFunc")
在Visual Studio中新建一个动态链接库项目,命名为libxml264-157,添加以下代码:
#pragma comment(linker, "/EXPORT:x264_10_frame_pop=libx264-159.x264_10_frame_pop") #pragma comment(linker, "/EXPORT:x264_10_frame_push=libx264-159.x264_10_frame_push") #pragma comment(linker, "/EXPORT:x264_10_frame_shift=libx264-159.x264_10_frame_shift") #pragma comment(linker, "/EXPORT:x264_10_frame_unshift=libx264-159.x264_10_frame_unshift") #pragma comment(linker, "/EXPORT:x264_10_threadpool_delete=libx264-159.x264_10_threadpool_delete") #pragma comment(linker, "/EXPORT:x264_10_threadpool_init=libx264-159.x264_10_threadpool_init") #pragma comment(linker, "/EXPORT:x264_10_threadpool_run=libx264-159.x264_10_threadpool_run") #pragma comment(linker, "/EXPORT:x264_10_threadpool_wait=libx264-159.x264_10_threadpool_wait") #pragma comment(linker, "/EXPORT:x264_8_frame_pop=libx264-159.x264_8_frame_pop") #pragma comment(linker, "/EXPORT:x264_8_frame_push=libx264-159.x264_8_frame_push") #pragma comment(linker, "/EXPORT:x264_8_frame_shift=libx264-159.x264_8_frame_shift") #pragma comment(linker, "/EXPORT:x264_8_frame_unshift=libx264-159.x264_8_frame_unshift") #pragma comment(linker, "/EXPORT:x264_8_threadpool_delete=libx264-159.x264_8_threadpool_delete") #pragma comment(linker, "/EXPORT:x264_8_threadpool_init=libx264-159.x264_8_threadpool_init") #pragma comment(linker, "/EXPORT:x264_8_threadpool_run=libx264-159.x264_8_threadpool_run") #pragma comment(linker, "/EXPORT:x264_8_threadpool_wait=libx264-159.x264_8_threadpool_wait") #pragma comment(linker, "/EXPORT:x264_chroma_format=libx264-159.x264_chroma_format") #pragma comment(linker, "/EXPORT:x264_cpu_detect=libx264-159.x264_cpu_detect") #pragma comment(linker, "/EXPORT:x264_cpu_names=libx264-159.x264_cpu_names") #pragma comment(linker, "/EXPORT:x264_cpu_num_processors=libx264-159.x264_cpu_num_processors") #pragma comment(linker, "/EXPORT:x264_encoder_close=libx264-159.x264_encoder_close") #pragma comment(linker, "/EXPORT:x264_encoder_delayed_frames=libx264-159.x264_encoder_delayed_frames") #pragma comment(linker, "/EXPORT:x264_encoder_encode=libx264-159.x264_encoder_encode") #pragma comment(linker, "/EXPORT:x264_encoder_headers=libx264-159.x264_encoder_headers") #pragma comment(linker, "/EXPORT:x264_encoder_intra_refresh=libx264-159.x264_encoder_intra_refresh") #pragma comment(linker, "/EXPORT:x264_encoder_invalidate_reference=libx264-159.x264_encoder_invalidate_reference") #pragma comment(linker, "/EXPORT:x264_encoder_maximum_delayed_frames=libx264-159.x264_encoder_maximum_delayed_frames") #pragma comment(linker, "/EXPORT:x264_encoder_open_157=libx264-159.x264_encoder_open_159") #pragma comment(linker, "/EXPORT:x264_encoder_parameters=libx264-159.x264_encoder_parameters") #pragma comment(linker, "/EXPORT:x264_encoder_reconfig=libx264-159.x264_encoder_reconfig") #pragma comment(linker, "/EXPORT:x264_free=libx264-159.x264_free") #pragma comment(linker, "/EXPORT:x264_levels=libx264-159.x264_levels") #pragma comment(linker, "/EXPORT:x264_log_default=libx264-159.x264_log_default") #pragma comment(linker, "/EXPORT:x264_log_internal=libx264-159.x264_log_internal") #pragma comment(linker, "/EXPORT:x264_malloc=libx264-159.x264_malloc") #pragma comment(linker, "/EXPORT:x264_mdate=libx264-159.x264_mdate") #pragma comment(linker, "/EXPORT:x264_nal_encode=libx264-159.x264_nal_encode") #pragma comment(linker, "/EXPORT:x264_param2string=libx264-159.x264_param2string") #pragma comment(linker, "/EXPORT:x264_param_apply_fastfirstpass=libx264-159.x264_param_apply_fastfirstpass") #pragma comment(linker, "/EXPORT:x264_param_apply_profile=libx264-159.x264_param_apply_profile") #pragma comment(linker, "/EXPORT:x264_param_default=libx264-159.x264_param_default") #pragma comment(linker, "/EXPORT:x264_param_default_preset=libx264-159.x264_param_default_preset") #pragma comment(linker, "/EXPORT:x264_param_parse=libx264-159.x264_param_parse") #pragma comment(linker, "/EXPORT:x264_picture_alloc=libx264-159.x264_picture_alloc") #pragma comment(linker, "/EXPORT:x264_picture_clean=libx264-159.x264_picture_clean") #pragma comment(linker, "/EXPORT:x264_picture_init=libx264-159.x264_picture_init") #pragma comment(linker, "/EXPORT:x264_reduce_fraction=libx264-159.x264_reduce_fraction") #pragma comment(linker, "/EXPORT:x264_reduce_fraction64=libx264-159.x264_reduce_fraction64") #pragma comment(linker, "/EXPORT:x264_slurp_file=libx264-159.x264_slurp_file") #pragma comment(linker, "/EXPORT:x264_threading_init=libx264-159.x264_threading_init")
生成libxml264-157.dll,就解决了这个问题。
标签:comment,函数,Windows,libx264,linker,159,转发器,pragma,x264 来源: https://www.cnblogs.com/JebediahKerman/p/Windows_Function_Forwarder.html