0

When I try to link librubberband.a I get: libavfilter/af_rubberband.c:236: error: undefined reference to 'rubberband_set_pitch_scale'

  1. I compiled rubberband for armv7a, and created a static library (rubberband.a). I checked the library, and It contained the needed symbols (using nm).

  2. I verified that librubberband.a is in the libpath (-L)

  3. I verified that extern C exists in the rubberband.c.h file.

Any ideas?

Eli
  • 707
  • 8
  • 16

1 Answers1

2

The error happened in the link stage. Make sure the link directory has been added to -L parameters of your compiler.

-L/directory/of/your/lib

And specify the library with -l option.

So make sure the option -L/directory/of/your/lib -lrubberband set for your compiler when you build ffmpeg with rubberband support.

If you didn't use pkg-config to add the library. You can use the option --extra-ldflags to add when configure ffmpeg before build.

./configure \
# some configure options
--extra-ldflags="-L/directory/of/your/lib -lrubberband" \
# more configure options

If you use pkg-config to find out the libraries. Just add the library.pc directory to PKG_CONFIG_PATH, and let the build system do the remaining.

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/directory/to/your/rubberband.pc

Updated

Finally make sure you link against to the same architecture of your library.

$ arm-linux-androideabi-readelf -h librubberband.a |grep 'Class\|Machine

For armeabi-v7a, it should be ELF32 and ARM.

Updated

I have cloned the source of rubberband from https://bitbucket.org/breakfastquay/rubberband

And found the function call rubberband_set_pitch_scale is defined at src/rubberband-c.cpp, this file is not include in Android.mk when build for Android (WHY?).

So you have to add this file to build.

RUBBERBAND_SRC_FILES = ... \
    $(RUBBERBAND_SRC_PATH)/rubberband-c.cpp

After build done, you need to create directory structure like below

    .
├── include
│   └── rubberband
│       ├── RubberBandStretcher.h
│       └── rubberband-c.h
└── lib
    ├── librubberband.a
    └── pkgconfig
        └── rubberband.pc

The file rubberband.pc was copied from rubberband.in.pc with some minor changes.

prefix=/path/to/rubberband/install/root
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: rubberband
Version: 1.8.1
Description: 
Libs: -L${libdir} -lrubberband -L/path/to/android/ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a -lgnustl_static
Cflags: -I${includedir} 

Then add

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/path/to/rubberband/install/root

before ./configure to tell ffmpeg find rubberband by pkg-config.

I have tried with the latest ffmpeg, it works.

alijandro
  • 11,627
  • 2
  • 58
  • 74
  • Thanks for your answer, Of course I put the directory of the lib next to the -L The -l is optional, the linker will search the -L path for a library (I tried it anyway, and it didn't help). Eli – Eli Jun 28 '17 at 07:35
  • @Eli Where is your rubberband installed? How did you configure your build? – alijandro Jun 28 '17 at 07:41
  • Its not "installed", I just produced the .a using Android.mk, and told the linker the location of it. – Eli Jun 28 '17 at 07:44
  • The Android.mk is this: – Eli Jun 28 '17 at 07:44
  • @Eli ok, how did you configure ffmpeg? – alijandro Jun 28 '17 at 07:47
  • Its too long for a comment – Eli Jun 28 '17 at 07:51
  • ./configure --enable-cross-compile --arch=arm --target-os=linux --prefix=/output --disable-shared --enable-static --cross-prefix=/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi- --sysroot=/android-ndk-r10e/platforms/android-14/arch-arm --enable-gpl --enable-memalign-hack --enable-ffmpeg --disable-ffplay --enable-libx264 --enable-zlib --enable-librubberband --extra-cflags='-I../x264 -I../libmp3lame -I../rubberband/inc -mfloat-abi=softfp -march=armv7-a -w' --extra-ldflags='-L../rubberband -L../x264 -L../libmp3lame -lc' – Eli Jun 28 '17 at 07:54
  • The configure passed OK, also the compile stage. – Eli Jun 28 '17 at 07:57
  • I didn't see `-lrubberband` option in your `--extra-ldflags` – alijandro Jun 28 '17 at 08:01
  • its because its optional, the linker finds without a problem the x264, and there is no -lx264 – Eli Jun 28 '17 at 08:05
  • And I did tried it with the -l option (as I told you before), and It didn't help – Eli Jun 28 '17 at 08:06
  • Sorry to tackle you like that... Its a hard problem, I did all the obvious stuff yesterday ;) – Eli Jun 28 '17 at 08:44
  • Thank! its looks very promising, I can't use pkg-config since NDK does not have it? how did you managed to overcome it? (I just removed the check from the configure script) – Eli Jul 02 '17 at 07:30
  • I managed to solve the issue, and I accepted your answer, because it gave me great directions to try. I solved my issue by ignoring the ffmpeg linker issues, and link using the ndk-build with the added stl paths (I took the idea from your pkg-config). Thanks for all your help!!! – Eli Jul 02 '17 at 11:44
  • NDK doesn't support `pkg-config`, but `pkg-config` is necessary for ffmpeg build if you use the traditional way `./configure` to build. You just build rubberband library with NDK, then provide rubberband library to ffmpeg, and ffmpeg use `pkg-config` to find the provided rubberband library. Anyway, congratulate you solved the issue by your own. – alijandro Jul 03 '17 at 02:13
  • @alijandro could you please help me how to use `--enable-rubberband` as suggested here https://ffmpeg.org/ffmpeg-filters.html#rubberband command for FFmpeg. – Kamal Nayan Jan 04 '22 at 09:06