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

atof linker error with armeabi #315

Closed
isuPatches opened this issue Mar 5, 2017 · 8 comments
Closed

atof linker error with armeabi #315

isuPatches opened this issue Mar 5, 2017 · 8 comments
Assignees

Comments

@isuPatches
Copy link

Description

atof linker error with armeabi.

I noticed while using 3.2.4 version of FFMPEG that atof has an undefined reference. As a work around I branched FFMPEG and changed atof to strtod(pointer, NULL).

error: undefined reference to 'atof'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Same details should be found here:
http://stackoverflow.com/questions/42601696/ffmpeg-with-android-sdks-16-25-and-ndk-14-atof-error

Environment Details

  • NDK Version: 14.0.3770861
  • Build sytem: ndk-build
  • Host OS: Mac
  • Compiler: Clang
  • ABI: armeabi
  • STL: ?? (Sorry...I should know this but I don't)
  • NDK API level: 16
  • Device API level: 16 and 19
@isuPatches isuPatches changed the title atof atof linker error with armeabi Mar 5, 2017
@DanAlbert DanAlbert self-assigned this Mar 5, 2017
@DanAlbert
Copy link
Member

I'm not able to reproduce this. Here's what I tried: https://gist.github.com/DanAlbert/edae02a0f432e186f60c2b9f852ae303

$ android-ndk-r14/ndk-build -B
[armeabi] Compile++ thumb: foo <= foo.cpp
[armeabi] StaticLibrary  : libstdc++.a
[armeabi] Executable     : foo
[armeabi] Install        : foo => libs/armeabi/foo
$ android-ndk-r14/ndk-build -B APP_UNIFIED_HEADERS=true
[armeabi] Compile++ thumb: foo <= foo.cpp
[armeabi] StaticLibrary  : libstdc++.a
[armeabi] Executable     : foo
[armeabi] Install        : foo => libs/armeabi/foo
$ android-ndk-r14/ndk-build -B APP_STL=c++_static
[armeabi] Compile++ thumb: foo <= foo.cpp
[armeabi] Executable     : foo
[armeabi] Install        : foo => libs/armeabi/foo
$ android-ndk-r14/ndk-build -B APP_UNIFIED_HEADERS=true APP_STL=gnustl_static
[armeabi] Compile++ thumb: foo <= foo.cpp
[armeabi] Executable     : foo
[armeabi] Install        : foo => libs/armeabi/foo
$ android-ndk-r14/ndk-build -B APP_STL=c++_static
[armeabi] Compile++ thumb: foo <= foo.cpp
[armeabi] Executable     : foo
[armeabi] Install        : foo => libs/armeabi/foo
$ android-ndk-r14/ndk-build -B APP_UNIFIED_HEADERS=true APP_STL=gnustl_static
[armeabi] Compile++ thumb: foo <= foo.cpp
[armeabi] Executable     : foo
[armeabi] Install        : foo => libs/armeabi/foo

Based on the stackoverflow post, I do have another theory. Is the ffmpeg build perhaps building some other library against a higher platform level and then linking that into the thing you're building against android-16? This might be a case of the first bullet point under https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md#Using-Mismatched-Prebuilt-Libraries

If your target API level is android-9, but you‘re using a prebuilt library that was built against android-16, the resulting app’s minimum API level is android-16. Failure to adhere to this will be visible at build time if the prebuilt library is static, but may not appear until run time for prebuilt shared libraries.

@DanAlbert
Copy link
Member

Ping? I'd like to get a fix for this into r14b, but I can't do that without a repro case.

@isuPatches
Copy link
Author

@DanAlbert Sorry for the delay...I'm seeing if I can reproduce locally and getting a test app set up with non-sensitive information that's the shortest path to reproduce...I'll hopefully have something before tomorrow morning for you.

@isuPatches
Copy link
Author

isuPatches commented Mar 14, 2017

@DanAlbert I've tried FFMPEG v3.2.4 built against both SDK and 24 and SDK 16...what I have boiled it down to is have a c file I have in jni/h264 that reproduces the issue:

#include <jni.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>

int main(int argc, char *argv[]){
  av_register_all();
  return 0;
}

#ifdef __cplusplus
}
#endif

and ffmpeg in /jni/h264/ffmpeg/build/.

I did not see the issue until I called av_register_all(). Before then I could build as normal. Even when I did:

int main(int argc, char *argv[]){
  printf("%lf\n", atof(argv[1]));
  return 0;
}  

It's a really bizarre issue.

APP_ABI := arm64-v8a armeabi armeabi-v7a x86 x86_64
APP_PLATFORM := android-16
APP_STL := gnustl_stati

What other details would you need? I've done the appropriate build clean steps as well (never can be too safe lol)

@DanAlbert
Copy link
Member

Are you building a pure upstream ffmpeg? Last time I looked they didn't have Android.mk files in the project so I'd need to know how you're building this.

If you can, the easiest thing would be for you to upload a test case, but I understand if you can't if the source is confidential.

@alexcohn
Copy link

How did you build your ffmpeg libraries? Maybe they were compiled for SDK 21, which does have atof() in libc. Now when you link your C file with these libraries, you need atof! But you build it with SDK 16, where atof was defined inline in stdlib.h.

Make sure that your ffmpeg libraries are built against NDK headers of SDK 16.

@enh
Copy link
Contributor

enh commented May 30, 2017

closing for lack of needed info.

@enh enh closed this as completed May 30, 2017
@DanAlbert
Copy link
Member

Alex's guess sounds pretty likely to me anyway, and that's the expected behavior until we get the compatlib in place.

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

No branches or pull requests

4 participants