使用 Eclipse 开发 JNI 应用程序(Java/C++ 组合)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1624344/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Developing JNI applications with Eclipse (Combined Java/C++)
提问by ointment
Have anyone successfully managed to setup a combined Java/C++ project for Eclipse?
有没有人成功地为 Eclipse 设置了一个组合的 Java/C++ 项目?
What I am trying to do is quite simple;
我想做的很简单;
1) Compile my Java sources
2) Run Javah to create the JNI interface
3) Compile all the C/C++ sources
4) Link native shared library + package the JAR
Hints or even real projects which work are much welcome.
非常受欢迎的提示甚至实际项目。
(Eclipse 3.5)
(日食 3.5)
采纳答案by alphazero
This really sounds like a job for a build system, like ant
. Simply configure your Java project to use the ant builder. You would still get the benefits of language specific support for your C++ and Java projects, and, one click build of the project.
这听起来真的像是构建系统的工作,比如ant
. 只需将您的 Java 项目配置为使用ant builder。您仍然可以从对 C++ 和 Java 项目的特定语言支持中获益,并且可以一键构建项目。
回答by Daff
I'm using the ant cpptasksfor realizing a JNI project with Eclipse only on Linux and Windows. It was some work to get it running with the MSVC (Windows) and the GNU C++ compiler (getting all compiler and linker flags properly since has been done with Visual Studio Magic before) but it was really worth it.
我仅在 Linux 和 Windows 上使用ant cpptasks来通过 Eclipse 实现 JNI 项目。让它与 MSVC (Windows) 和 GNU C++ 编译器一起运行需要一些工作(正确获取所有编译器和链接器标志,因为之前已使用 Visual Studio Magic 完成),但这确实值得。
For generating the C++ Header with javah and all the other Tasks you mentioned Antwill probably be the tool of choice, too.
对于使用 javah 生成 C++ Header 以及您提到的所有其他任务,Ant也可能是首选工具。
回答by dape
http://www.cs.umanitoba.ca/~eclipse/8-JNI.pdfI think this is what you wanted.Maybe a little old.
http://www.cs.umanitoba.ca/~eclipse/8-JNI.pdf我想这就是你想要的。也许有点老了。