error: undefined reference to ‘cv::Mat::~Mat()‘解决AndroidStudio集成OpenVC出现的编译报错问题

这篇具有很好参考价值的文章主要介绍了error: undefined reference to ‘cv::Mat::~Mat()‘解决AndroidStudio集成OpenVC出现的编译报错问题。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

前言

本来这种类型的博客不是笔者想写的,不过这个问题,笔者经过网上一番搜索却没有可用的解决方案,因此分享出来帮助大家填坑。

集成OpenVC静态库

OpenCV官方的Android SDK在这里下载,集成方法就不多介绍了,可以看这两位博主的文章:

  •  小小情意的​ Android 接入 OpenCV库的三种方式 ​
  •  春末的南方城市的在Android端集成OpenCV的三种方式

CMakeList.txt完整配置文件如下:

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.18.1)

# Declares and names the project.

project("opencv_mobile")

include_directories(include)

# 设置Debug编译模式,这样才能生成符号表,方便使用addr2line来定位内存地址对应代码行
set(CMAKE_BUILD_TYPE DEBUG)

# 设置变量
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fexceptions -fopenmp -static-openmp")
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv/sdk/native/jni)
find_package(OpenCV 4.5.4 REQUIRED core features2d highgui imgproc photo video)
message("OpenCV_FOUND is ${OpenCV_FOUND}")
message("OpenCV_LIBS is ${OpenCV_LIBS}")

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
        opencv_mobile

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        opencv_mobile.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
        opencv_mobile
        ${OpenCV_LIBS}
        # Links the target library to the log library
        # included in the NDK.
        android
        ${log-lib})

官方提供的OpenCVConfig.cmake也告诉了我们怎么集成。

# ===================================================================================
#  The OpenCV CMake configuration file
#
#             ** File generated automatically, do not modify **
#
#  Usage from an external project:
#    In your CMakeLists.txt, add these lines:
#
#    find_package(OpenCV REQUIRED)
#    include_directories(${OpenCV_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11
#    target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS})
#
#    Or you can search for specific OpenCV modules:
#
#    find_package(OpenCV REQUIRED core videoio)
#
#    If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE.
#
#    This file will define the following variables:
#      - OpenCV_LIBS                     : The list of all imported targets for OpenCV modules.
#      - OpenCV_INCLUDE_DIRS             : The OpenCV include directories.
#      - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API.
#      - OpenCV_VERSION                  : The version of this OpenCV build: "4.5.4"
#      - OpenCV_VERSION_MAJOR            : Major version part of OpenCV_VERSION: "4"
#      - OpenCV_VERSION_MINOR            : Minor version part of OpenCV_VERSION: "5"
#      - OpenCV_VERSION_PATCH            : Patch version part of OpenCV_VERSION: "4"
#      - OpenCV_VERSION_STATUS           : Development status of this build: ""
#
# ===================================================================================

代码结构如下:

error: undefined reference to ‘cv::Mat::~Mat()‘解决AndroidStudio集成OpenVC出现的编译报错问题

 源码在这里查看:https://github.com/xiangang/AndroidDevelopmentPractices/tree/develop

编译遇到的问题

集成OpenCV虽然很简单,但有时候也需要一点点运气。像笔者运气就不太好,下面是编译报错的完整日志。

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':OpenCVMobile:buildCMakeDebug[armeabi-v7a]'.
> Build command failed.
  Error while executing process /home/xiangang/Android/Sdk/cmake/3.18.1/bin/ninja with arguments {-C /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/.cxx/Debug/4r2c6mo1/armeabi-v7a opencv_mobile}
  ninja: Entering directory `/work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/.cxx/Debug/4r2c6mo1/armeabi-v7a'
  [1/1] Linking CXX shared library /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/build/intermediates/cxx/Debug/4r2c6mo1/obj/armeabi-v7a/libopencv_mobile.so
  FAILED: /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/build/intermediates/cxx/Debug/4r2c6mo1/obj/armeabi-v7a/libopencv_mobile.so 
  : && /work/android/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi23 --gcc-toolchain=/work/android/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/work/android/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security   -frtti -fexceptions -fopenmp -static-openmp -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libopencv_mobile.so -o /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/build/intermediates/cxx/Debug/4r2c6mo1/obj/armeabi-v7a/libopencv_mobile.so CMakeFiles/opencv_mobile.dir/opencv_mobile.cpp.o  -landroid  /work/android/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/23/liblog.so  -latomic -lm && :
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:23: error: undefined reference to 'cv::Mat::Mat(int, int, int, void*, unsigned int)'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:24: error: undefined reference to 'cv::Mat::Mat()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:25: error: undefined reference to 'cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:53: error: undefined reference to 'cv::Mat::release()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:54: error: undefined reference to 'cv::Mat::release()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:55: error: undefined reference to 'cv::Mat::~Mat()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:55: error: undefined reference to 'cv::Mat::~Mat()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:55: error: undefined reference to 'cv::Mat::~Mat()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:55: error: undefined reference to 'cv::Mat::~Mat()'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.
  


* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':OpenCVMobile:buildCMakeRelWithDebInfo[armeabi-v7a]'.
> Build command failed.
  Error while executing process /home/xiangang/Android/Sdk/cmake/3.18.1/bin/ninja with arguments {-C /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/.cxx/RelWithDebInfo/442v101w/armeabi-v7a opencv_mobile}
  ninja: Entering directory `/work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/.cxx/RelWithDebInfo/442v101w/armeabi-v7a'
  [1/1] Linking CXX shared library /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/build/intermediates/cxx/RelWithDebInfo/442v101w/obj/armeabi-v7a/libopencv_mobile.so
  FAILED: /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/build/intermediates/cxx/RelWithDebInfo/442v101w/obj/armeabi-v7a/libopencv_mobile.so 
  : && /work/android/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi23 --gcc-toolchain=/work/android/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/work/android/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security   -frtti -fexceptions -fopenmp -static-openmp -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libopencv_mobile.so -o /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/build/intermediates/cxx/RelWithDebInfo/442v101w/obj/armeabi-v7a/libopencv_mobile.so CMakeFiles/opencv_mobile.dir/opencv_mobile.cpp.o  -landroid  /work/android/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/23/liblog.so  -latomic -lm && :
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:23: error: undefined reference to 'cv::Mat::Mat(int, int, int, void*, unsigned int)'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:24: error: undefined reference to 'cv::Mat::Mat()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:25: error: undefined reference to 'cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:53: error: undefined reference to 'cv::Mat::release()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:54: error: undefined reference to 'cv::Mat::release()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:55: error: undefined reference to 'cv::Mat::~Mat()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:55: error: undefined reference to 'cv::Mat::~Mat()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:55: error: undefined reference to 'cv::Mat::~Mat()'
  /work/AndroidStudioProjects/AndroidDevelopmentPractices/AndroidJetpackComposeSample/OpenCVMobile/src/main/cpp/opencv_mobile.cpp:55: error: undefined reference to 'cv::Mat::~Mat()'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.
  


* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
72 actionable tasks: 4 executed, 68 up-to-date

对应的源码如下:

#include <jni.h>
#include <string>
#include "common.h"
#include <android/bitmap.h>
// for native window JNI
#include <android/native_window_jni.h>
#include <android/native_window.h>
// for native OpenCV JNI
#include "opencv2/core/core.hpp"
#include "opencv2/core/mat.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;

extern "C"
JNIEXPORT void JNICALL
Java_com_nxg_opencv_OpenCVMobile_renderYuvDataOnSurface(JNIEnv *env, jclass clazz, jint width,
                                                        jint height, jbyteArray yuv_data,
                                                        jobject surface) {
    // yuv转rgba
    jbyte *data = env->GetByteArrayElements(yuv_data, nullptr);
    cv::Mat yuvImg(height + height / 2, width, CV_8UC1, data);
    cv::Mat rgbImg;
    cv::cvtColor(yuvImg, rgbImg, COLOR_YUV2RGBA_IYUV);
    // 这两行代码用于翻转的,用不到,这里注释掉
    //cv::transpose(yuvImg, rgbImg);
    //cv::flip(yuvImg, rgbImg, 1);
    //获取ANativeWindow
    ANativeWindow *window = ANativeWindow_fromSurface(env, surface);
    ANativeWindow_acquire(window);
    //设置ANativeWindow相关参数,包括宽/高/像素格式
    ANativeWindow_setBuffersGeometry(window, rgbImg.cols, rgbImg.rows, WINDOW_FORMAT_RGBA_8888);
    ANativeWindow_Buffer outBuffer;
    // 调用ANativeWindow_lock锁定后台的缓冲部分,并获取surface缓冲区的地址
    if (int32_t err = ANativeWindow_lock(window, &outBuffer, nullptr)) {
        LOGE("ANativeWindow_lock failed with error code: %d\n", err);
        ANativeWindow_release(window);
    }
    // 拷贝rgb数据到缓冲区
    auto *outPtr = reinterpret_cast<uint8_t *>(outBuffer.bits);
    int dst_line_size = outBuffer.stride * 4;
    //一行一行拷贝
    for (int i = 0; i < outBuffer.height; ++i) {
        //从源src所指的内存地址的起始位置开始拷贝n个字节到目标dest所指的内存地址的起始位置中
        memcpy(outPtr + i * dst_line_size, rgbImg.data + i * rgbImg.cols * 4, dst_line_size);
    }
    //绘制
    ANativeWindow_unlockAndPost(window);
    //用完释放
    ANativeWindow_release(window);
    env->ReleaseByteArrayElements(yuv_data, data, 0);
    yuvImg.release();
    rgbImg.release();
}

简简单单的代码,怎么就出问题了?检查了头文件,没错。源码,也没错。那就只有一个可能,CMake编译出问题。回过头看集成OpenCV的关键CMake代码:

set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv/sdk/native/jni)
find_package(OpenCV 4.5.4 REQUIRED core features2d highgui imgproc photo video)
message("OpenCV_DIR is ${OpenCV_DIR}")
message("OpenCV_FOUND is ${OpenCV_FOUND}")
message("OpenCV_LIBS is ${OpenCV_LIBS}")
target_link_libraries( # Specifies the target library.
        opencv_mobile
        ${OpenCV_LIBS}
        # Links the target library to the log library
        # included in the NDK.
        android
        ${log-lib})

加了关键变量的打印。最后发现是OpenCV_LIBS变量为空,难怪有问题。

那就看下OpenCVConfig.cmake是在哪里给OpenCV_LIBS赋值的,继续在关键地方加打印如下:

error: undefined reference to ‘cv::Mat::~Mat()‘解决AndroidStudio集成OpenVC出现的编译报错问题

 发现压根没执行到这里。继续往上排查到。最终发现在下图这个红色框部分提前return了。原因是因为编译用的Android版本低于OpenCV_ANDROID_NATIVE_API_LEVEL定义的版本,至此,真相大白!

error: undefined reference to ‘cv::Mat::~Mat()‘解决AndroidStudio集成OpenVC出现的编译报错问题

既然知道原因了,那就好办了。

解决办法

修改minSdkVersion

如果项目没有限制,则直接把对应module的build.gralde的minSdkVersion改为OpenCV_ANDROID_NATIVE_API_LEVEL一样的版本,并重新编译即可。

android {
    compileSdk = BuildConfig.compileSdk
    defaultConfig {
        minSdk = 24
        targetSdk = BuildConfig.targetSdkVersion
        testInstrumentationRunner = BuildConfig.testInstrumentationRunner
        consumerProguardFiles("consumer-rules.pro")
    }
}

修改OpenCV_ANDROID_NATIVE_API_LEVEL

你可能会想,我直接改OpenCV_ANDROID_NATIVE_API_LEVEL行不行,比如我项目里是minSdkVersion=23,OpenCV_ANDROID_NATIVE_API_LEVEL的值是24,我直接把OpenCV_ANDROID_NATIVE_API_LEVEL改成23行不行?

笔者实测发现是可以的,但是否有其它未知的问题那就不得而知了。这个方式不是很建议,要相信OpenVC这么要求是有它的道理的。文章来源地址https://www.toymoban.com/news/detail-467771.html

到了这里,关于error: undefined reference to ‘cv::Mat::~Mat()‘解决AndroidStudio集成OpenVC出现的编译报错问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Dev C++中出现 undefined reference to XXX 错误的解决方式

            主函数中调用在其他文件中定义的函数,编译报错:未定义的引用xxx。         原理:编译器在生成可执行文件的过程包括预处理、编译、汇编、链接,这4个过程,这个问题一般出现在 链接 过程,所谓的链接过程,就是把不同的目标文件粘合在一起,生成一

    2024年02月03日
    浏览(43)
  • 调用OpenCV库出现: undefined reference to `xxxxx‘ 的解决办法(使用MinGW编译器)

    我的CMakeLists.txt如下: cpp代码如下: 因为我的c++程序采用mingw64编译,所以使用 之后,总是出现undefined reference to cv::Mat::Mat()等一系列的undefined reference to XXX 原因是没有正确链接到动态库。或者之前有安装其他版本的opencv 重新编译一份OpenCV的源码再使用 编译过程参考: https

    2024年02月05日
    浏览(66)
  • windows下MSYS、MinGW编译环境使用网络API时报错:undefined reference to `inet_pton‘解决办法

    mingw-gcc环境使用网络需要加上库 -lws2_32。 如果是使用的是Qt Creator那么需要在.pro文件中加入一行: win32:LIBS += -lws2_32 。 当在项目中使用 inet_pton、inet_pton、inet_ntop、inet_ntop 等ip转换函数时会报未定义的错误,这是因为在windows系统下这些函数的定义在头文件 winsock2.h 和 ws2tcpip

    2024年02月11日
    浏览(42)
  • Keil 5下出现Error: L6218E: Undefined symbol Delay(unsigned) (referred from main.o).的解决方法

            今天在给stm32f407vgt6点灯时,想实现循环闪烁,于是想从以前的工程中移植一个delay延时函数,移植后编译时发现出现错误: Error: L6218E: Undefined symbol Delay(unsigned) (referred from main.o).的解决方法         在确定了头文件Include路径的包含和.c文件的添加后,想起之前

    2024年02月12日
    浏览(49)
  • [STM32问题解决(1)]一类问题的解决办法——编译错误:XXX.axf: Error: L6218E: Undefined symbol xxx (referred from xxxx.o).

    学习自己手动搭建一个STM32HAL库工程模板文件的时候,我发现了有6个错误,6个错误的类型是一样的,其中有3个通过添加hal_rcc.h和hal_gpio.c文件得以解决。所以另外3个我也想到了时缺少了对应的.c文件导致的错误。 但是在 STM32F1xx_HAL_Driver 文件夹中,我没有找到类似如有“rcc”

    2023年04月17日
    浏览(47)
  • CMake 链接时出现undefined reference to 错误

    一、问题背景 之前新建了一个项目项目文件分布为 1. src/MROR.cpp 2.include/MROR.h 3.main.cpp 执行cmake出现undefined reference toxx,显示main函数中的类成员函数调用没有声明,但是所有声明已经在MROR.h中写了 二、解决方法 我查了很多网上资料 解决方法 1) 可能MROR.cpp文件没有链接到项目,

    2024年02月09日
    浏览(60)
  • nmealib库编译提示 undefined reference to `ceil‘

    下载了nmealib库文件,默认工程进行编译,报错,提示如下: 网上搜索,因为使用了 ceil 数学相关的库,说是链接需要添加 -lm 的参数。 官方的 Makefile 文件 可以看到 LIBS 已经包含了 lm 。目前的报错该怎么解决呢? 解决办法:修改 LIBS 中 lm 的位置,放在后面。 如下: 再次编

    2024年01月20日
    浏览(39)
  • HAL库 编译错误:XXX.axf: Error: L6218E: Undefined symbol xxx (referred from xxxx.o)的可能原因之一及解决方法

    我在学习STM32 HAL库版本时遇到了这种编译问题  由于是刚开始学习STM32代码跟例程是一样的,所以代码不可能出错。我去网上寻找答案看到了 (7条消息) (已解决)STM32报错Error: L6218E: Undefined symbol assert_param (referred from misc.o)._老龙QAQ的博客-CSDN博客 于是按照他的方法试验了一下

    2024年02月11日
    浏览(55)
  • 关于STM32 Hal 库函数编写的程序 在编译时报错 :“Error: L6218E: Undefined symbol 函数名 (referred from xx.o)” 的解决办法

    一开始以为是没有包含头文件,将头文件包含后,再次进行编译仍然不能解决。并且在进行源文件跳转时出现下面的问题: 去源文件进行查看,确实存在该函数,但是就是不能跳转回去,检查函数名拼写后无果。所以尝试另外的解决办法。 参考https://blog.csdn.net/zhizuwei/articl

    2024年02月14日
    浏览(53)
  • undefined reference to `__android_log_print‘

    今天给JNI的C代码添加“__android_log_print”日志打印,发现报错。 这里对原因进行分析 build.gradle中 CCallJava.c(JNI文件中) so文件没有没有添加log的链接库,添加“LOCAL_LDLIBS := -llog”即可

    2024年01月20日
    浏览(94)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包