gpt4 book ai didi

c++ - 使用 Android NDK 在 C++ 中对 gnuradio 的 undefined reference

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:56:22 25 4
gpt4 key购买 nike

我正在尝试访问 Android 中的 gnuradio 功能,特别是带通滤波器功能。在不调用任何函数的情况下,ndk-build 会编译代码。当我调用 complex_band_pass(...) 函数时,它给我一个 undefined reference 的错误:

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

在我的 Android.mk 文件中这个特定文件:

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)

在我的 rx_filter.cpp 文件中:

#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

注意:gnuradio已经安装在默认位置

我该怎么做才能访问 android 中的 gnuradio 函数?

另一个问题是如何在 Android NDK 环境中创建带通滤波器?

提前致谢,与此同时,我将像过去几天一样自行解决问题。如果我找到解决方案,我会发布它。

最佳答案

首先你可以检查成员函数是否已经存在

nm libgnuradio.a | grep gr_firdes::complex_band_pass

或者 纳米 libgnuradio.a | grep complex_band_pass

添加

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

如果你调试完整的构建日志那么

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

关于c++ - 使用 Android NDK 在 C++ 中对 gnuradio 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18155029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com