Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Bionic - undefined reference to 'operator new(unsigned int)' #1130

Closed
hypothermic opened this issue Nov 10, 2019 · 8 comments
Closed
Assignees
Labels
Milestone

Comments

@hypothermic
Copy link

Description

Compiler gives the following error when building:

/usr/local/google/buildbot/src/android/ndk-release-r20/bionic/libc/bionic/locale.cpp:155: error: undefined reference to 'operator new(unsigned int)'

Project "app/src/cpp" folder: https://github.com/hypothermic/bionic-bug-repro
Using cmake version 3.10.2

Environment Details

  • NDK Version: 20.0.5594570
  • Build system: CMake
  • Host OS: Ubuntu 18.04 with kernel 4.15
  • ABI: arm64-v8a
  • NDK API level: 21
  • Device API level: 29
@DanAlbert
Copy link
Member

What's in the build.gradle? There's nothing obviously wrong from what I can see in that project, and without the rest of the project we can't reproduce the error.

@hypothermic
Copy link
Author

The repository to the full project: https://github.com/hypothermic/ValaAndroid

@DanAlbert
Copy link
Member

Nothing immediately suspicious there either. I'll try building it later and see what I find.

@AntonioNoack
Copy link

I have the same issue, when trying to compile xmllib2 for Android.
My flags for xmllib:
#define LIBXML_TREE_ENABLED 1
#define LIBXML_OUTPUT_ENABLED 1
#define LIBXML_SAX1_ENABLED 1
#define HAVE_CTYPE_H 1

@hypothermic
Copy link
Author

@DanAlbert Hi, have you built it?

@DanAlbert
Copy link
Member

I've been out sick for a couple weeks. Haven't had a chance.

@DanAlbert DanAlbert added this to the r22 milestone Apr 11, 2020
@DanAlbert
Copy link
Member

And when I was back I'd totally forgotten about this... sorry about that!

Seems like this is an issue with using the static libc++ with anything that ends up using the locale code in libandroid_support? The linker script for libc++.a is INPUT(-lc++_static -lc++abi -landroid_support), and for libc++.so it's INPUT(-landroid_support -lc++_shared). If the locale.cpp code from libandroid_support ends up being used, it needs new/delete. I think we just need to do the usual linker nonsense of -lc++_static -lc++abi -landroid_support -lc++_static -lc++abi, but haven't tested yet (I'm not sure if we can use --begin-group/--end-group in a linker script).

I'm not sure why this wouldn't show up in testing. I suspect none of our tests use enough of libc++ to end up depending on locale code when using libc++_static?

@DanAlbert DanAlbert self-assigned this Apr 11, 2020
arcadia-devtools pushed a commit to catboost/catboost that referenced this issue May 26, 2020
Make `android_support` and `c++abi` link order-agnostic to prevent
link errors like `undefined reference to 'operator new(unsigned int)'`.

Upstream issue in Android NDK r21: android/ndk#1130

ref:7fe1884295c588b137d1bfa7954051e536c3566c
@DanAlbert
Copy link
Member

https://android-review.googlesource.com/c/platform/ndk/+/1326079 fixes the linker scripts. A bit more testing revealed that this is also fixed by just using LLD since it'll re-search earlier libraries for missing symbols, so this would have gone away for most users in r22 anyway :)

Apparently this has actually been broken since r17. I guess most code does a pretty good job of avoiding newlocale? That, or just not many people building for pre-21.

arcadia-devtools pushed a commit to catboost/catboost that referenced this issue Jan 18, 2022
Make `android_support` and `c++abi` link order-agnostic to prevent
link errors like `undefined reference to 'operator new(unsigned int)'`.

Upstream issue in Android NDK r21: android/ndk#1130

ref:7fe1884295c588b137d1bfa7954051e536c3566c
arcadia-devtools pushed a commit to catboost/catboost that referenced this issue Jan 25, 2022
We are using LLD and NDK r23 at the time.
[This issue](android/ndk#1130) should be fixed.

ref:52e634c8ea6cccb53897f4dbf3ff49ea9ee4f949
robot-piglet pushed a commit to catboost/catboost that referenced this issue Jan 15, 2023
Make `android_support` and `c++abi` link order-agnostic to prevent
link errors like `undefined reference to 'operator new(unsigned int)'`.

Upstream issue in Android NDK r21: android/ndk#1130

ref:7fe1884295c588b137d1bfa7954051e536c3566c
robot-piglet pushed a commit to catboost/catboost that referenced this issue Jan 16, 2023
We are using LLD and NDK r23 at the time.
[This issue](android/ndk#1130) should be fixed.

ref:52e634c8ea6cccb53897f4dbf3ff49ea9ee4f949
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants