Android Build Teststub -- Linker failed "undefined symbol" Android.bp // maybe missing an include path?

676 views
Skip to first unread message

jrw

unread,
Mar 31, 2020, 5:56:56 PM3/31/20
to Android Building
Hello,

i'm facing an issue with the linker, most likely because of lack of knowledge :/

i think i lack an include path or something like that, but i could not find something in the documentation or got confused by the Android.bp files.

i try to simple example fuzzer:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sonic.h"
#include "wave.h"

#define BUFFER_SIZE 2048

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

   
short inBuffer[BUFFER_SIZE];
   
int foo = 10;
   
int bar = 1;

    waveFile batz
= openInputWaveFile((char*)data, &foo,&bar);

    readFromWaveFile
(batz,inBuffer,size);

   
return 0;
}


for that, i setup an Android.bp file in the subfolder "fuzz" i created.

cc_fuzz {
    name
: "sonic_fuzz",
    host_supported
: false,
    srcs
: [
       
"sonic_fuzz.cc",
   
],
    shared_libs
: [
   
"libsonic",
   
],
    cflags
: [
   
"-g",
   
],
    cpp_std
: "c++98",
}

and after i tried to build it, i get:

ld.lld: error: undefined symbol: openInputWaveFile(char*, int*, int*)
>>> referenced by sonic_fuzz.cc:16 (external/sonic/fuzz/sonic_fuzz.cc:16)
>>>               out/soong/.intermediates/external/sonic/fuzz/sonic_fuzz/android_arm64_armv8-a_cortex-a73_hwasan_fuzzer/obj/external/sonic/fuzz/sonic_fuzz.o:(LLVMFuzzerTestOneInput)

ld
.lld: error: undefined symbol: readFromWaveFile(waveFileStruct*, short*, int)
>>> referenced by sonic_fuzz.cc:18 (external/sonic/fuzz/sonic_fuzz.cc:18)
>>>               out/soong/.intermediates/external/sonic/fuzz/sonic_fuzz/android_arm64_armv8-a_cortex-a73_hwasan_fuzzer/obj/external/sonic/fuzz/sonic_fuzz.o:(LLVMFuzzerTestOneInput)
clang
-10: error: linker command failed with exit code 1 (use -v to see invocation)
23:28:40 ninja failed with: exit status 1

#### failed to build some targets (13:07 (mm:ss)) ####

do i need to include some path for the sonic library in the Android.bp file or something?

Thanks for your help
Hannes

Dan Willemsen

unread,
Mar 31, 2020, 5:59:46 PM3/31/20
to Android Building
The `libsonic` in Android only includes `sonic.c`: https://cs.android.com/android/platform/superproject/+/master:external/sonic/Android.bp

openInputWaveFile and readFromWaveFile are in `wave.c`

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/68c9f746-afc2-4870-b724-1b18c7cda9cf%40googlegroups.com.

jrw

unread,
Mar 31, 2020, 6:15:37 PM3/31/20
to Android Building
no wonder the symbol isn't found. thanks for the fast response!
Reply all
Reply to author
Forward
0 new messages