Closed gary23chen closed 8 years ago
Hmm, this could be related to #26. On my machine it compiles fine both with an old and a new libav version, but maybe the #ifdef
in libav.cpp
is not entirely correct.
Can you try replacing #define AV_FRAME_FREE avcodec_free_frame
with #define AV_FRAME_FREE av_frame_free
? If this works, can you try to find out what LIBAVCODEC_VERSION_INT
is in your version of libav?
Thank you for you reply so quickly. I replaced #define AV_FRAME_FREE avcodec_free_frame with #define AV_FRAME_FREE av_frame_free, but it still reported the similar errors:
/root/musly/musly-master/libmusly/decoders/libav.cpp: In member function âvirtual std::vector<float, std::allocator
How can I find out what LIBAVCODEC_VERSION_INT is?
I find the LIBAVCODEC_VERSION_INT in libav sourcecode:
LIBAVCODEC_VERSION_MINOR, \
LIBAVCODEC_VERSION_MICRO)
I have tried to replace the version of libav from 0.8 to 11.7, the above problem of "av_frame_free not declared" is resolved. but I met a new problem while linking: [root@dev02 build]# make [ 12%] Built target musly_resample Scanning dependencies of target libmusly [ 16%] Building C object libmusly/CMakeFiles/libmusly.dir/kissfft/kiss_fft.c.o [ 20%] Building C object libmusly/CMakeFiles/libmusly.dir/kissfft/kiss_fftr.c.o [ 24%] Building CXX object libmusly/CMakeFiles/libmusly.dir/methods/mandelellis.cpp.o [ 28%] Building CXX object libmusly/CMakeFiles/libmusly.dir/methods/timbre.cpp.o [ 32%] Building CXX object libmusly/CMakeFiles/libmusly.dir/decoders/libav.cpp.o [ 36%] Building CXX object libmusly/CMakeFiles/libmusly.dir/resampler.cpp.o [ 40%] Building CXX object libmusly/CMakeFiles/libmusly.dir/plugins.cpp.o [ 44%] Building CXX object libmusly/CMakeFiles/libmusly.dir/method.cpp.o [ 48%] Building CXX object libmusly/CMakeFiles/libmusly.dir/decoder.cpp.o [ 52%] Building CXX object libmusly/CMakeFiles/libmusly.dir/windowfunction.cpp.o [ 56%] Building CXX object libmusly/CMakeFiles/libmusly.dir/powerspectrum.cpp.o [ 60%] Building CXX object libmusly/CMakeFiles/libmusly.dir/melspectrum.cpp.o [ 64%] Building CXX object libmusly/CMakeFiles/libmusly.dir/discretecosinetransform.cpp.o [ 68%] Building CXX object libmusly/CMakeFiles/libmusly.dir/mfcc.cpp.o [ 72%] Building CXX object libmusly/CMakeFiles/libmusly.dir/gaussianstatistics.cpp.o [ 76%] Building CXX object libmusly/CMakeFiles/libmusly.dir/mutualproximity.cpp.o [ 80%] Building CXX object libmusly/CMakeFiles/libmusly.dir/lib.cpp.o Linking CXX shared library libmusly.so /usr/bin/ld: /usr/local/lib/libavcodec.a(allcodecs.o): relocation R_X86_64_32 against `ff_a64multi_encoder' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libavcodec.a: could not read symbols: Bad value collect2: ld returned 1 exit status make[2]: * [libmusly/libmusly.so] Error 1 make[1]: * [libmusly/CMakeFiles/libmusly.dir/all] Error 2 make: *\ [all] Error 2
I find the LIBAVCODEC_VERSION_INT in libav sourcecode:
define LIBAVCODEC_VERSION_MAJOR 53
define LIBAVCODEC_VERSION_MINOR 35
define LIBAVCODEC_VERSION_MICRO 0
This is libav 0.8.1. Checking my version (the one of Ubuntu 14.04 LTS), I see that I actually have libav 9, and libavcodec_free_frame
was only introduced in that version (http://upstream.rosalinux.ru/compat_reports/libav/0.8.17_to_9/abi_compat_report.html). So the current code is incompatible with libav 0.8, sorry! I'll see if this is the only incompatibility and fix it, but probably only by next week.
Anyway, we've discovered several bugs in libav in the last years, so I'd recommend using the latest version if you can.
Linking CXX shared library libmusly.so /usr/bin/ld: /usr/local/lib/libavcodec.a(allcodecs.o): relocation R_X86_64_32 against `ff_a64multi_encoder' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libavcodec.a: could not read symbols: Bad value
It's easier if you build shared libraries for libav. When compiling libav for CentOS, run:
git clone git://git.libav.org/libav.git libav
cd libav
mkdir build && cd build
../configure --enable-shared --disable-symver
make && make install
Otherwise, you may try to recompile with -fPIC
as indicated; to do so you will need to change the CXXFLAGS
when configuring musly. Let me know if it works!
I have tried to build libav as shared libraries, but it didn't work. Then I try to recompile the musly with -fPIC. As I have no experience on cpp compiling, I find that there is CXX_FLAGS in CMakeCache.txt, so I try to modify the CMakeCache.txt as: //CXX compiler. CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
//Flags used by the compiler during all build types. CMAKE_CXX_FLAGS:STRING=-fPIC
But the issue still bothered me after recompile. Could you give me some more information about how to change the CXXFLAGS? Thank you!
I have tried to build libav as shared libraries, but it didn't work.
What exactly happened when you tried? I've successfully built it on centOS before.
Could you give me some more information about how to change the CXXFLAGS?
If you configure with ccmake ..
, you can toggle to advanced mode (with t
) and enter it in the GUI. If you configure with cmake ..
, just append cmake .. -DCXXFLAGS=-fPIC
. Not sure if this will really work, I haven't tried compiling against a static libav.
Great! I reconfigured the musly by appending "cmake .. -DCMAKE_CXX_FLAGS:STRING=-fPIC" and recompiled it successfully. Now it works on my centOS! Thank you very much!
BTW, I build libav as shared libraries successfully yesterday, but it didn't work for resolving the linking problem in musly compiling. It looks like musly must be built with -fPIC as what I did just now.
Good to know you've got it working! I've been able to build musly on centOS without changing the CMAKE_CXX_FLAGS
, though. Anyway, I will try to fix the libav 0.8 incompatibility next week. Thanks for reporting it!
I've updated libav.cpp
so it works with libav 0.8 again. Thanks for your report! (I still recommend using a later version of libav, or ffmpeg.)
Thank you for informing me this.
I try to build musly on centOS. I installed eigen 3 and libav 0.8 successfully. But I met some problems when compiling musly: /root/musly/musly-master/libmusly/decoders/libav.cpp: In member function âvirtual std::vector<float, std::allocator > musly::decoders::libav::decodeto_22050hz_mono_float(const std::string&, float, float)â:
/root/musly/musly-master/libmusly/decoders/libav.cpp:369: error: avcodec_free_frame was not declared in this scope
/root/musly/musly-master/libmusly/decoders/libav.cpp:403: error: avcodec_free_frame was not declared in this scope
/root/musly/musly-master/libmusly/decoders/libav.cpp:483: error: avcodec_free_frame was not declared in this scope
could you please give me some advise? thanks a lot!