[solved] Linker Failed trying to build for Android

[solved] Linker Failed trying to build for Android
0.0 0

#1

Whatever I did fixed the issue. I created a new project and pulled over the /jni/ folder and compared the rest of my android.proj folder for differences.


Anyone run into this issue? Both NDK r9d and r10d failed here. Note that I have changed my Application.mk to the following:

APP_STL := c++_static
APP_CPPFLAGS := -std=c++11 -frtti -fexceptions -DCOCOS2D_DEBUG=1 -g -ggdb -O1
APP_ABI := armeabi
APP_OPTIM := debug
APP_PLATFORM := android-10
[armeabi] Compile++ thumb: cocos_ui_static <= UIWebView.cpp
[armeabi] Compile++ thumb: cocos_ui_static <= UIWebViewImpl-android.cpp
In file included from /Users/stevetranby/dev/projects/scgame-x-32/proj.android/../cocos2d/cocos/ui/UIWebViewImpl-android.cpp:31:0:
/Users/stevetranby/android/android-ndk-r10d/sources/cxx-stl/llvm-libc++/libcxx/include/string: In member function 'void cocos2d::experimental::ui::WebViewImpl::loadFile(const string&)':
/Users/stevetranby/android/android-ndk-r10d/sources/cxx-stl/llvm-libc++/libcxx/include/string:641:35: error: inlining failed in call to always_inline 'static constexpr bool std::__1::char_traits<char>::eq(std::__1::char_traits<char>::char_type, std::__1::char_traits<char>::char_type) throw ()': indirect function call with a yet undetermined callee
     static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
                                   ^
In file included from /Users/stevetranby/android/android-ndk-r10d/sources/cxx-stl/llvm-libc++/libcxx/include/__hash_table:18:0,
                 from /Users/stevetranby/android/android-ndk-r10d/sources/cxx-stl/llvm-libc++/libcxx/include/unordered_map:350,
                 from /Users/stevetranby/dev/projects/scgame-x-32/proj.android/../cocos2d/cocos/ui/UIWebViewImpl-android.cpp:29:
/Users/stevetranby/android/android-ndk-r10d/sources/cxx-stl/llvm-libc++/libcxx/include/algorithm:1050:13: error: called from here
             if (__pred(*__first1, *__j))
             ^
At global scope:
cc1plus: warning: unrecognized command line option "-Wno-extern-c-compat"
cc1plus: warning: unrecognized command line option "-Wno-extern-c-compat"
make: *** [obj/local/armeabi/objs-debug/cocos_ui_static/UIWebViewImpl-android.o] Error 1
make: Leaving directory `/Users/stevetranby/dev/projects/scgame-x-32/proj.android'
Ndk build failed!

#2

This happens when building with release mode can you help me? What should I do?


#3

Not sure.
Are you on the latest cocos github (or at least 3.15+)?
Are you on the latest NDK? r11+?
I essentially am not sure what I did. It’s possible that the Application.mk flags fixed it, possibly just some commit fixed it.

Do you get the exact error? or just something similar?


#4

Same exact.
I just build with APP_OPTIM := debug and everything worked
when APP_OPTIM was set to release it falied.


#5

What version are you using? That file looks to have changed.

Check UIWebViewImpl-android.cpp and UIWebViewImpl-android.h for inline and/or always_inline. This makes some sense as to why it only occurs when optimizing (release) and gcc apparently is having issues with an “always inline” function not actually being declared as “c++ inline”.

Since the current HEAD version doesn’t have inline I’m guessing you’re using a somewhat older version.

I’ve also since moved on to using clang even for android builds. I’m also using Android Studio and NDK (15.1xxxxx).

Hope this helps you figure it out.


#6

The same type of error is the same it’s not rooted from the same place though.
I have code in my game that causes this error namely error: inlining failed in call to always_inline 'static constexpr bool std::__1::char_traits<char>::eq(std::__1::char_traits<char>::char_type, std::__1::char_traits<char>::char_type) throw ()': indirect function call with a yet undetermined callee static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT ^


#7

Is there more to the error output?
It’s only showing the std library trace (gives no context).

Maybe it’s resolving a different function, maybe you have an #define eq( macro in your code?

In the end this is really more a debugging question, less a cocos2d one. Unless of course you can trace it to specific cocos2d library code.


#8

I commented out the code that was producing the error and then the same type of error came up from the cocos2d-x file?
Whatever I just build using APP_OPTIM := debug and it works the same.


#9

Well good luck. If you want to share the entire error stream I’ll take one more guess.


#10

I use APP_STL := gnustl_static, then build success