Android NDK:Eclipse 参数和 javah

发布于 2025-01-06 14:28:43 字数 1870 浏览 1 评论 0原文

我花了好几个小时在上面,却没有前进一寸。我已经重做了好几次这个项目了,没有任何东西留在外面的地方。希望这里有人能指出一些方向。

在 Linux Eclipse IDE 面板上 >运行>外部工具>外部工具配置:

Name: Dev javah
Tab [main]:
* location: /usr/java/jdk1.6.0_25/bin/javah
* working directory: ${workspace_loc:/Dev/bin}
* Arguments: ??

我已经尝试过:

* Arguments: -d ${workspace_loc:/Dev/jni} com.dev.DevActivity ${project_classpath:Dev} com.pkgpub.DevActivity

这给了我:

1 error
javadoc: error - Illegal package name: "/home/user/dev/Dev/bin/classes"

并且还尝试了:

* Arguments: -d ${workspace_loc:/Dev/jni} com.dev.DevActivity

这给了...

error: cannot access com.dev.DevActivity
class file for com.dev.DevActivity not found
javadoc: error - Class com.dev.DevActivity not found.
Error: No classes were specified on the command line.  Try -help.

类似于 -

* Arguments: -d ${workspace_loc:/Dev/jni} com.pkgpub.DevActivity

这给了我:

error: cannot access com.pkgpub.DevActivity
class file for com.pkgpub.DevActivity not found
javadoc: error - Class com.pkgpub.DevActivity not found.
Error: No classes were specified on the command line.  Try -help.

但是当我运行时:

which javah
/usr/bin/which: no javah in (/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/user/android-sdks/tools:/home/user/android-sdks/platform-tools:/opt/android/android-ndk-r7:/home/user/.local/bin:/home/user/bin:/home/user/android-sdks/tools:/home/user/android-sdks/platform-tools:/opt/android/android-ndk-r7:/home/user/android-sdks/tools:/home/user/android-sdks/platform-tools:/opt/android/android-ndk-r7)

问题是...项目没有编译,因为 javah 对Eclipse NDK,或者由于参数细节缺少某些内容?在这种情况下,如何修复它?

谢谢。

I spent hours and hours on it not moving an inch forward. I have redone the project several times and nothing else is left outside places. Hope someone here can shed some light pointing out some direction.

On Linux Eclipse IDE panel > Run > External Tools > External Tools Configurations:

Name: Dev javah
Tab [main]:
* location: /usr/java/jdk1.6.0_25/bin/javah
* working directory: ${workspace_loc:/Dev/bin}
* Arguments: ??

I have tried:

* Arguments: -d ${workspace_loc:/Dev/jni} com.dev.DevActivity ${project_classpath:Dev} com.pkgpub.DevActivity

which gives me:

1 error
javadoc: error - Illegal package name: "/home/user/dev/Dev/bin/classes"

and also tried:

* Arguments: -d ${workspace_loc:/Dev/jni} com.dev.DevActivity

That gives...

error: cannot access com.dev.DevActivity
class file for com.dev.DevActivity not found
javadoc: error - Class com.dev.DevActivity not found.
Error: No classes were specified on the command line.  Try -help.

similarly to -

* Arguments: -d ${workspace_loc:/Dev/jni} com.pkgpub.DevActivity

That gives me:

error: cannot access com.pkgpub.DevActivity
class file for com.pkgpub.DevActivity not found
javadoc: error - Class com.pkgpub.DevActivity not found.
Error: No classes were specified on the command line.  Try -help.

But when I run:

which javah
/usr/bin/which: no javah in (/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/user/android-sdks/tools:/home/user/android-sdks/platform-tools:/opt/android/android-ndk-r7:/home/user/.local/bin:/home/user/bin:/home/user/android-sdks/tools:/home/user/android-sdks/platform-tools:/opt/android/android-ndk-r7:/home/user/android-sdks/tools:/home/user/android-sdks/platform-tools:/opt/android/android-ndk-r7)

The question is... the project is not compiling because javah is not visible to Eclipse NDK, or due to parameter details that something is missing? And in such case, how to get it fixed?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

埋情葬爱 2025-01-13 14:28:43

尝试添加

-classpath bin/classes

作为 javah 的参数

try adding

-classpath bin/classes

as parameter to javah

忆离笙 2025-01-13 14:28:43

特别适用于 Android:

在 bin 之后使用类,例如 project_location/bin/classes,这在 Linux Fedora 上对我有用

javah -d /var/www/project/jni/ -classpath /var/www/project/bin/classes/ com.android.TestClass

Specially for Android:

use classes right after bin like project_location/bin/classes, this worked for me on Linux Fedora

javah -d /var/www/project/jni/ -classpath /var/www/project/bin/classes/ com.android.TestClass
樱娆 2025-01-13 14:28:43

@BlackBelt - 谢谢你的建议!

这是有效的参数,解决了编译过程的 javah 方面的问题:

-d ${workspace_loc:/Dev/jni} com.pkgpub.Dev -classpath ${workspace_loc:/Dev/bin/classes/} com.pkgpub.Dev

其中 pkgpub 是包名称,Dev 是项目名称。值得一提的是,该项目有以下文件:\src\Dev.java; \jni\Dev.c; \jni\Dev.h; \bin...\pkgpub\Dev.class。

现在它生成具有正确内容的文件 jni/com_pkgpub_Dev.h。这太棒了!

然而 ndk-build 仍然没有完全链接,并且没有生成 com_pkgpub_Dev.c 文件。所以,从项目>项目构建 - 出现消息:

**** Build of configuration Build (GNU) for project Dev ****
ndk-build 
make: *** No rule to make target `jni/com_pkgpub_Dev.c', needed by `obj/local/armeabi/objs/dev/com_pkgpub_Dev.o'.  Stop.
**** Build Finished ****

从该消息看来,文件 /jni/Android.mk 中应该缺少某些参数:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS    := -DHAVE_INTTYPES_H
LOCAL_MODULE    := dev
LOCAL_SRC_FILES := com_pkgpub_Dev.c Dev.c
include $(BUILD_SHARED_LIBRARY) 

要解决此问题,只需创建缺少的文件“jni/com_pkgpub_Dev.c”。该文件内容应根据文件“jni/com_pkgpub_Dev.h”中包含的自动生成的代码手动制作。

现在,它起作用了!

@BlackBelt - thanks man for your suggestion!

Here is the parameter that worked, solving the javah side for the compiling process:

-d ${workspace_loc:/Dev/jni} com.pkgpub.Dev -classpath ${workspace_loc:/Dev/bin/classes/} com.pkgpub.Dev

Where pkgpub is the package name, and Dev is the project name. It is worth to mention that the project has the files: \src\Dev.java; \jni\Dev.c; \jni\Dev.h; \bin...\pkgpub\Dev.class.

Now it generates the file jni/com_pkgpub_Dev.h with the right content. Which is great!

However the ndk-build is still not completely linking, and does not generate the com_pkgpub_Dev.c file. So, from Project > Project Build - comes the message:

**** Build of configuration Build (GNU) for project Dev ****
ndk-build 
make: *** No rule to make target `jni/com_pkgpub_Dev.c', needed by `obj/local/armeabi/objs/dev/com_pkgpub_Dev.o'.  Stop.
**** Build Finished ****

From this message it sounds like some parameter should be missing from the file /jni/Android.mk:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS    := -DHAVE_INTTYPES_H
LOCAL_MODULE    := dev
LOCAL_SRC_FILES := com_pkgpub_Dev.c Dev.c
include $(BUILD_SHARED_LIBRARY) 

To solve it, it is just necessary to create the missing file "jni/com_pkgpub_Dev.c". This file content should be manually made based on the automatic generated code contained in the file "jni/com_pkgpub_Dev.h".

Now, it works!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文