Open Nikoli opened 10 years ago
I have libav-9.10
My gcc doesn't like the --as-needed option. So I cannot test any fix. It appears to be the order of the object files on the command line. I've changed the Makefile for libav-bitrate. I won't change the others until you can confirm that this resolves the issue.
I confirm that moving *.o options before LDFLAGS solves problem:
$ x86_64-pc-linux-gnu-gcc -march=corei7-avx -O2 -pipe libav-bitrate.c progress.o -Wl,--hash-style=gnu -Wl,-O1 -Wl,--as-needed -lswscale -lavcodec -lavformat -lavutil -o libav-bitrate
$ objdump -p libav-bitrate|grep NEEDED|sort
NEEDED libavcodec.so.54
NEEDED libavformat.so.54
NEEDED libavutil.so.52
NEEDED libc.so.6
As you can see --as-needed works, it does not link to not used libswscale. Your changes to Makefile are partly wrong, because placing --as-needed after -l* is no-op:
$ x86_64-pc-linux-gnu-gcc -march=corei7-avx -O2 -pipe libav-bitrate.c progress.o -lswscale -lavcodec -lavformat -lavutil -ljpeg -lfftw3 -lz -Wl,--hash-style=gnu -Wl,-O1 -Wl,--as-needed -o libav-bitrate
$ objdump -p libav-bitrate|grep NEEDED|sort
NEEDED libavcodec.so.54
NEEDED libavformat.so.54
NEEDED libavutil.so.52
NEEDED libc.so.6
NEEDED libfftw3.so.3
NEEDED libjpeg.so.8
NEEDED libswscale.so.2
NEEDED libz.so.1
Building with --as-needed detected 2 other bugs: 1) yuvilace does not need fftw 2) opencv related flags should be OPENCV_LIBS=-lopencv_core -lopencv_highgui -lopencv_imgproc
Updated my pull request, this is now fixed in https://github.com/silicontrip/lavtools/pull/18
Hope this last Makefile change fixes these issues.
Works mostly fine now, but what about yuvilace.c? It does not link to fftw:
$ objdump -p yuvilace|grep NEEDED
NEEDED libmjpegutils-2.0.so.0
NEEDED libc.so.6
May be it is not used at all?
$ cat /tmp/cppcheck_lavtools.log|grep yuvilace
[yuvilace.c:91]: (style) The scope of the variable 't' can be reduced.
[yuvilace.c:349]: (style) The scope of the variable 'drop_frames' can be reduced.
[yuvilace.c:193]: (style) Unused variable: frame_data_size
[yuvilace.c:197]: (style) Variable 'l' is assigned a value that is never used.
[yuvilace.c:197]: (style) Variable 'f' is assigned a value that is never used.
[yuvilace.c:199]: (style) Variable 'points' is assigned a value that is never used.
[yuvilace.c:199]: (style) Variable 'window' is assigned a value that is never used.
[yuvilace.c:369]: (style) Variable 'drop_frames' is assigned a value that is never used.
[yuvilace.c:366]: (style) Variable 'src_interlacing' is assigned a value that is never used.
[yuvilace.c:396]: (style) Variable 'src_frame_rate' is assigned a value that is never used.
yuvilace was an experiment to detect interlacing using an fft. It was unable to fulfil it's original design, so is left in a half built state. I may've tried other methods of detecting interlacing, implemented in this code.
A lot if not all targets fail to build with '-Wl,--as-needed', without they build fine: