[Libav-user] ff_log2_tab defined multiple times in the fmpeg 1.1 libraries, bug or feature ??

"René J.V. Bertin" rjvbertin at gmail.com
Wed Feb 13 18:07:13 CET 2013


On Feb 13, 2013, at 16:47, Alexey Belkevich wrote:

>> Hello, can someone please explain the reason (and how to cope with) that ff_log2_tab is defined multiple times with #include "libavutil/log2_tab.c" in the ffmpeg v1.1 libraries like libavcodec 54.91.102 and companions ??

You have identified the reason; ff_log2_tab is defined in libavutil/log2_tab.c, which is included in files of the same name from libavcodec, libavformat and libswresample. This may not be a problem when using dynamic libraries, but with static libraries it can become one if the linker is forced to link in those different log2_tab.o modules. And this will be the case even if the dependency is "intra-library" (i.e., a module from lavc accessing ff_log2_tab and another module from lavf also accessing ff_log2_tab). 

Do you by any chance use this array in your own code? Do you confirm that you do not get the error when linking ffmpeg in the same build environment? Either way, add a line V=1 to the ffmpeg toplevel Makefile so you get to follow the full build process, with the detailed invocations. It could be that you'll find that the option to suppress or ignore duplicate symbols is specified at the relevant linking stages.

Anyway, it seems like a workaround shouldn't be too hard. Is there any reason to have ff_log2_tab be exported by 4 libraries, if at all (and if so, is there a reason not to have an inter-library dependency on libavutil)? If not, a macro could be defined in lib{avcodec,avformat,swresample}/*config.h to do a bit of C++-style name mangling on ff_log2_tab, such that each library includes it from the same single source but using a slightly different name. Or simpler, since the number of files using the variable isn't large (and the table itself isn't either), just declare it static in a header file and include that in each file that accesses the variable.



More information about the Libav-user mailing list