2

I am trying to get access to gnuradio functions in Android, specifically the bandpass filter function. Without calling any functions, ndk-build compiles the code. When I call the complex_band_pass(...) function, it gives me an error of undefined reference to:

Error from ndk-build:

error: undefined reference to 'gr_firdes::complex_band_pass(double, double, double, double, double, gr_firdes::win_type, double)' collect2: ld returned 1 exit status

in my Android.mk file for this particular file:

include $(CLEAR_VARS)
LOCAL_MODULE    := rxfilter
LOCAL_SRC_FILES := src/rx_filter.cpp
LOCAL_C_INCLUDES += /usr/local/include/gnuradio \
                /usr/local/include \
                ${ANDROID_NDK_ROOT}/sources/cxx-stl/stlport/stlport
LOCAL_CFLAGS := -DANDROID -DUSE_LIBLOG
LOCAL_SHARED_LIBRARIES +=  rtlsdr
LOCAL_STATIC_LIBRARIES :=  /usr/local/lib/libgnuradio #doesn't seem to help
LOCAL_LDLIBS +=  -llog
include $(BUILD_SHARED_LIBRARY)

in my rx_filter.cpp file:

#include <jni.h>
#include <cmath>
#include <math.h>
#include <vector>

#include <gr_firdes.h>

using namespace std;

static void attemptToAccessGnuRadio()
{
    // gr_firdes is a class
    gr_firdes gg;
    // compiles without this line
    gg.complex_band_pass(1.0, 24000.0, 100.0, 500.0, 1.0); 
}

#ifdef __cplusplus
extern "C" {
#endif


JNIEXPORT jint JNICALL Java_rtlsdr_MainActivity_nativeRtlSdrFm(JNIEnv *envp, jobject objp)
{    
    return 1;
}

#ifdef __cplusplus
}
#endif

Note: gnuradio has been installed in the default location

What can I do to get access to gnuradio functions in android?

An alternative question would be how do I create a bandpass filter in Android NDK environment?

Thanks in advance, in the meantime I will be troubleshooting it myself as I have for the past few days. If I find the solution, I will post it.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
user2010136
  • 141
  • 1
  • 7

2 Answers2

0

First you can check the member function is already in

nm libgnuradio.a | grep gr_firdes::complex_band_pass

or nm libgnuradio.a | grep complex_band_pass

and

Adds

LOCAL_LDFLAGS := -L/usr/local/lib
LOCAL_LDLIBS +=  -llog -lgnuradio

If you debug the full build log then

build V=1 will be helpful or use VERBOSE=1
0

gr_firdes::complex_band_pass(double, double, double, double, double, gr_firdes::win_type, double) should be in libgnuradio-filter.a

You can verify via nm as mentioned in one of the other answers (calling c++filt can help demangle the function names. For example: $ nm libgnuradio-filter.a | c++filt | grep complex_band 000024c8 T gr::filter::firdes::complex_band_pass(double, double, double, double, double, gr::filter::firdes::win_type, double)

Your error should be resolved by making sure your LOCAL_LDLIBS includes -lgnuradio-filter

runexe
  • 363
  • 1
  • 2
  • 6