Skip to content

NDK r11 undefined reference #23

Closed
Closed

Description

@SimonMarquis

Since NDK r11, bcopy is no longer defined in libc and triggers an error during linkage of libusrsctp for instance:
error: undefined reference to 'bcopy'

Application.mk:

APP_STL := c++_static
APP_OPTIM := release
APP_ABI := armeabi-v7a x86
APP_PLATFORM := android-14
NDK_TOOLCHAIN_VERSION := clang

Android.mk

LOCAL_CFLAGS            +=  -g
LOCAL_STATIC_LIBRARIES := libusrsctp
LOCAL_LDLIBS            := -lm -llog -landroid -lz
LOCAL_ARM_MODE          := arm
LOCAL_CPPFLAGS          += -std=c++11
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/cpufeatures)

Is this issue related to #1 ?

Activity

  1. DanAlbert commented on Mar 16, 2016

    @DanAlbert
    Contributor

    Is libusrsctp something that you're building yourself, or a prebuilt library you're including? My test using everything but libusrsctp from your example works fine (my source file was a use of bcopy), so I'm guessing it's a prebuilt library.

  2. SimonMarquis commented on Mar 16, 2016

    @SimonMarquis
    Author

    It's indeed a prebuilt library (built from source before this step)

  3. DanAlbert commented on Mar 16, 2016

    @DanAlbert
    Contributor

    Is it something that can be rebuilt with r11? That would solve the problem.

    I don't know enough about the NDK ecosystem to know how widespread this kind of thing might be. How common is it to use prebuilt static libraries? (note that if it was a shared libusrsctp, it would actually link and load just fine)

  4. joakim-noah commented on Mar 17, 2016

    @joakim-noah

    I'll note that libusrsctp is open-source, so it can certainly be recompiled. That doesn't preclude the question of closed static libraries though.

  5. DanAlbert commented on Mar 17, 2016

    @DanAlbert
    Contributor

    Ack. We'd trimmed down the NDK stub libraries to match the current state of the headers (cases like bcopy are now just a macro instead of a real function). As it turns out that breaks ABI compatibility with static libraries...

    We'll have to add back a bunch of those symbols, since having those gone doesn't help anyone (the symbols that are actually private implementation details will remain hidden, but bcopy and the like are perfectly reasonable).

  6. SimonMarquis commented on Mar 17, 2016

    @SimonMarquis
    Author

    I re-built it with latest NDK r11 without any issue 👍
    I'm using static library because of how the current build process is done throughout our internal projects.

    @DanAlbert you said bcopy is now a macro, can you tell me into what it results? (a private bcopy implementation or memmove?)
    Thanks

  7. DanAlbert commented on Mar 17, 2016

    @DanAlbert
    Contributor

    #define bcopy(b1, b2, len) (void)(__builtin_memmove((b2), (b1), (len)))

    (I checked to be sure, and it is correctly defined as such across every API level, so no surprises there.)

  8. SimonMarquis commented on Mar 17, 2016

    @SimonMarquis
    Author

    Awsome!
    I've read that bcopy was not standard and somewhat slow compared to memmove.
    Thanks again for the quick support.

  9. DanAlbert commented on Mar 17, 2016

    @DanAlbert
    Contributor

    Glad to hear it.

    As far as adding back the symbols so we keep compatibility between r10 and r11 static libraries, I'm going to hold off to see if we get more reports of this. Compatibility for static libraries is something that is fairly fragile anyway (might even break compiler to compiler), so I'm leaning toward believing this isn't the norm.

    If more reports come in though, then it will be clear that I was wrong and we'll get it fixed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions