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

cargo-apk compilation problem #23

Open
hanxiaohuivc opened this issue Apr 13, 2023 · 10 comments
Open

cargo-apk compilation problem #23

hanxiaohuivc opened this issue Apr 13, 2023 · 10 comments

Comments

@hanxiaohuivc
Copy link

cargo-apk compilation problem
Excuse me, when I compile using the "cargo apk build" command on both windows and linux, the following error occurs: Error: Path "/home/develop/cargo-apk/target/aarch64-linux-android/debug/libndk_build.so" doesn't exist.
What is the cause of this? How to compile it correctly?
Thanks.

@JohnScience
Copy link

@hanxiaohuivc In my case, I had to rename the name of the library. cargo apk doesn't seem to respect [lib] section in Cargo.toml.

@MarijnS95
Copy link
Member

cargo apk doesn't seem to respect [lib] section in Cargo.toml.

It does since #26, but that hasn't been released yet because this crate is officially deprecated in favour of xbuild.

Perhaps I'll do one more final release with the last few contributions, and a clear marker at the top of the README.


The error @hanxiaohuivc is facing sounds like they have not set their [lib] to compile as a cdylib. We now have more robust checking/forcing for that in #28. Though strangely ndk-build is also the name of the support crate for cargo-apk, both of which are host tools and should unlikely be cross-compiled for Android (unless you're running this from Termux, but then you should not be using cargo apk because they are plain libs/exes, not an APK).

@mvvvv
Copy link

mvvvv commented Sep 14, 2023

I have the same problem since I move my main.rs in examples directory.
Error: Path "/home/mv/dvlt/abacaba/abacaba/target/aarch64-linux-android/debug/examples/libskybox1.so" doesn't exist.

@MarijnS95
Copy link
Member

@mvvvv have you configured your examples to compile as cdylib as well? See how the examples within this repo do it:

[[example]]
name = "hello_world"
crate-type = ["cdylib"]

@mvvvv
Copy link

mvvvv commented Sep 15, 2023

Thanks, it works perfectly

@mvvvv
Copy link

mvvvv commented Sep 15, 2023

Too bad. Now I cannot launch my example compiled for linux.
[[example]] name = "hello_world" crate-type = ["bin"]
works only for linux

[[example]] name = "hello_world" crate-type = ["bin","cdylib"]
works only for android.

Any Idea ?

@mvvvv
Copy link

mvvvv commented Sep 15, 2023

Something realy ugly is that with ["bin"] if an old file aarch64 libskybox1.so was previously successfully built, then this old file is packaged in the apk and the build is successfull.

@MarijnS95
Copy link
Member

Agreed, it's ugly and unfortunate but not something we can very easily work around. Having two examples is likely your best bet for the time being.

@mvvvv
Copy link

mvvvv commented Sep 21, 2023

I've found the solution. I create a symbolic link of the example, set te example crate-type to "cdylib" and run the link for PC tests. it works well with VS code and launch.json.

@MarijnS95
Copy link
Member

Such tricks also exist with path= in Cargo.toml. It's ugly but hard to work around until we get better integration with cargo.

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

No branches or pull requests

4 participants