Incompatible Implicit Declaration of Built-In Function Warning Using NDK with LAME

流过昼夜 提交于 2019-12-19 09:29:14

问题


I'm trying to follow the tutorial located at the following location

http://developer.samsung.com/android/technical-docs/Porting-and-using-LAME-MP3-on-Android-with-JNI

The gist of this is that it allows one to use the LAME MP3 encoder with JNI.

I followed each of the steps mentioned in the tutorial. My project is located at

C:\workspace\

and is called 'LAME_Test'. Per the section labeled Compilation with NDK in the tutorial, I went ahead and made a makefile called 'Android.mk' as is enclosed below this post.

I'm running Windows 7 on a 64-bit machine. I do have Cygwin and NDK installed and have tested that my setup works on another project that I'm working on. However, when I go to

/cygdrive/c/workspace/LAME_Test/jni

on Cygwin and issue the following command

 /cygdrive/c/Android/android-ndk-r8b/ndk-build

given that the NDK is located at

C:\Android\android-ndk-r8b

the compilation spits out a bunch of warnings like these

warning: incompatible implicit declaration of built-in function 'memset' [enabled by default]                                                                                                   

I'm enclosing a small snippet of the warnings at the bottom of this post (because the list of warnings is really big and may just add clutter - rather than add value).

Was wondering if there's a slick way to resolve these warnings and get a nice, clean, compile.

P.S: I will add that I was able to build + run the sample project in the link above (LAME4Android). This required the compilation of the native code. So, it looks like the the project does, in fact, build fine despite all the warnings. I initially thought it was broken because of the warnings. However, it would indeed be really great if there were some way to fix the warnings.

Contents of Android.mk File

LOCAL_PATH := $(call my-dir)

    include $(CLEAR_VARS)

    LOCAL_MODULE        := libmp3lame
    LOCAL_SRC_FILES     := \
    ./libmp3lame/bitstream.c \
    ./libmp3lame/encoder.c \
    ./libmp3lame/fft.c \
    ./libmp3lame/gain_analysis.c \
    ./libmp3lame/id3tag.c \
    ./libmp3lame/lame.c \
    ./libmp3lame/mpglib_interface.c \
    ./libmp3lame/newmdct.c \
    ./libmp3lame/presets.c \
    ./libmp3lame/psymodel.c \
    ./libmp3lame/quantize.c \
    ./libmp3lame/quantize_pvt.c \
    ./libmp3lame/reservoir.c \
    ./libmp3lame/set_get.c \
    ./libmp3lame/tables.c \
    ./libmp3lame/takehiro.c \
    ./libmp3lame/util.c \
    ./libmp3lame/vbrquantize.c \
    ./libmp3lame/VbrTag.c \
    ./libmp3lame/version.c

    LOCAL_LDLIBS := -llog

    include $(BUILD_SHARED_LIBRARY)

Log of Incompatible Implicit Declaration of Built-In Function Warnings

$ /cygdrive/c/Android/android-ndk-r8b/ndk-build
Cygwin         : Generating dependency file converter script
Compile thumb  : mp3lame <= bitstream.c
Compile thumb  : mp3lame <= encoder.c
C:/workspace/LAME_Test/jni/./libmp3lame/encoder.c: In function 'lame_encode_frame_init':
C:/workspace/LAME_Test/jni/./libmp3lame/encoder.c:202:9: warning: incompatible implicit declaration of built-in function 'memset' [enabled by default]                                                                                                 
C:/workspace/LAME_Test/jni/./libmp3lame/encoder.c: In function 'lame_encode_mp3_frame':
C:/workspace/LAME_Test/jni/./libmp3lame/encoder.c:471:17: warning: incompatible implicit declaration of built-in function 'bcopy' [enabled by default]                                                                                                    
Compile thumb  : mp3lame <= fft.c
Compile thumb  : mp3lame <= gain_analysis.c
and so on...

回答1:


After a lot of searching it looks like the answer I was looking for was found here

Lame MP3 Encoder compile for Android

The key for me was to ensure that the following line was added to my Android.mk file

LOCAL_CFLAGS = -DSTDC_HEADERS

as mentioned by James Zhang.

I'm enclosing my complete makefile below this post so what I'm saying is perfectly clear.

Contents of Updated Android.mk File

LOCAL_PATH := $(call my-dir)

    include $(CLEAR_VARS)

    LOCAL_MODULE        := libmp3lame
    LOCAL_SRC_FILES     := \
    ./libmp3lame/bitstream.c \
    ./libmp3lame/encoder.c \
    ./libmp3lame/fft.c \
    ./libmp3lame/gain_analysis.c \
    ./libmp3lame/id3tag.c \
    ./libmp3lame/lame.c \
    ./libmp3lame/mpglib_interface.c \
    ./libmp3lame/newmdct.c \
    ./libmp3lame/presets.c \
    ./libmp3lame/psymodel.c \
    ./libmp3lame/quantize.c \
    ./libmp3lame/quantize_pvt.c \
    ./libmp3lame/reservoir.c \
    ./libmp3lame/set_get.c \
    ./libmp3lame/tables.c \
    ./libmp3lame/takehiro.c \
    ./libmp3lame/util.c \
    ./libmp3lame/vbrquantize.c \
    ./libmp3lame/VbrTag.c \
    ./libmp3lame/version.c 

    LOCAL_LDLIBS := -llog
    LOCAL_CFLAGS = -DSTDC_HEADERS

    include $(BUILD_SHARED_LIBRARY)


来源:https://stackoverflow.com/questions/13303083/incompatible-implicit-declaration-of-built-in-function-warning-using-ndk-with-la

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!