Comments (15)
The good news: I got it working!
The bad news: I still have to find out how…
Will analyze a bit more and then post step by step how it works reproducibly for me.
from tools-android.
Thanks for your feedback! One step that’s missing is setting the NDK path in the app settings > SDK Location. If you’re on a Mac you should set it to the custom NDK that is installed by the toolchain in:
~/Library/Android/android-ndk-r20-clang-r353983c1
Can you check if that helps with the linker error?
from tools-android.
I can't find "App settings".
Do you mean "Android NDK location" in File > Project Structure… > SDK Location?
Setting it there doesn't help.
from tools-android.
Yeah that’s the right setting.
I found that for me, if I understand it correctly _ZNSt6__ndk111__call_onceERVmPvPFvS2_E
is defined in (not referenced by) libgnustep-base.so. Can you run the following and see if you get the same result?
$ nm ~/Library/Android/GNUstep/x86/lib/libgnustep-base.so | grep _ZNSt6__ndk111__call_onceERVmPvPFvS2_E
00758380 T _ZNSt6__ndk111__call_onceERVmPvPFvS2_E
from tools-android.
Also, does the hello-objectivec example work for you?
from tools-android.
The hello-objectivec example works perfectly, and that without any "Android NDK location" setting!
My result:
$ nm ~/Library/Android/GNUstep/x86/lib/libgnustep-base.so | grep _ZNSt6__ndk111__call_onceERVmPvPFvS2_E
U _ZNSt6__ndk111__call_onceERVmPvPFvS2_E
from tools-android.
Hmm interesting. Looks like your libgnustep-base.so (unlike mine) doesn’t define the function. Could you attach your (zipped) ~/Library/Android/GNUstep/build.log
?
That being said, question is why the example still works... I noticed in step 6 above you wrote that you call System.loadLibrary()
in an init method. Can you try putting it in a static initializer as in the example?
static {
System.loadLibrary("native-lib");
}
from tools-android.
I'm on Kotlin, so static won't work here. I tried to do it according to the "Native C++" Android Studio template (like below) which also doesn't work:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
initializeGNUstep(this);
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val navView: BottomNavigationView = findViewById(R.id.nav_view)
val navController = findNavController(R.id.nav_host_fragment)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
val appBarConfiguration = AppBarConfiguration(
setOf(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications, R.id.navigation_temperatures
)
)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
}
external fun initializeGNUstep(context: Context?)
companion object {
// Used to load the 'native-lib' library on application startup.
init {
System.loadLibrary("native-lib")
}
}
}
from tools-android.
I’ve never used Kotlin – could you try it with a Java project just to narrow it down further?
from tools-android.
Kotlin can't be the issue:
a) I get the same problem with a brand new Java Project (no Kotlin, no AndroidX)
b) I can convert your hello-objectivec and its MainActivity to Kotlin while still being able to load native-lib
from tools-android.
I see. I have no idea why the example project works and a new project doesn’t, and I cannot reproduce the issue. But the core issue seems to be that your GNUstep library file doesn’t define some symbols that mine does. If you could send me your build.log I can see if I can spot some differences in your build process that might be specific to your machine/setup.
from tools-android.
This pull request would document what worked for me: #8.
from tools-android.
Thanks for the PR! Can you tell what the missing bit was to get it working in the end?
from tools-android.
In the end I tried so much stuff that I'm not sure what exactly worked but I suspect step 6: "Link to C++" was missing.
from tools-android.
I fixed the underlying issue causing the linker error with _ZNSt6__ndk111__call_onceERVmPvPFvS2_E
: the toolchain libraries were not correctly linking against the shared C++ runtime library.
Please try rebuilding the toolchain with the latest changes, and also update your Gradle setup to use the shared C++ runtime library like this:
gnustep/android-examples@d3f5aba
Regarding instructions to integrate this in your own project I hope to be able to create a standalone CMake toolchain file that can simply be included in Android Studio (that’s why I haven’t merged your PR yet).
from tools-android.
Related Issues (12)
- How can I learn more about it? HOT 3
- Building libxml2 fails HOT 1
- libxml2 not found when building libxslt HOT 2
- release version should include ndk version information HOT 1
- Building with NDK r25 fails HOT 1
- x86 build fails due relocation linker error against libffi on x86
- Build fails in libdispatch on macOS 12.6 HOT 2
- Build failure in libffi with NDK r26
- Build failure in libcurl with NDK r26 HOT 2
- GNUstep sources are built without optimization and debug info
- Error when building against API level < 28 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tools-android.