是从Ubuntu构建适用于Alpine的JDK可行吗?

huangapple go评论74阅读模式
英文:

Is it feasible to build jdk for alpine from ubuntu?

问题

可以从Ubuntu构建适用于Alpine的JDK吗?

我从Ubuntu构建了JDK 11,然后将构建上传到我的Alpine。

然而,Alpine一直显示./java: 未找到

我该怎么办?

是从Ubuntu构建适用于Alpine的JDK可行吗?

英文:

Is it feasible to build jdk for alpine from ubuntu?

I built jdk11 from ubuntu and then upload the build to my alpine.

However, alpine keeps saying ./java: not found

how do I do?

是从Ubuntu构建适用于Alpine的JDK可行吗?

答案1

得分: 1

> 在Ubuntu上为Alpine构建JDK是可行的。首先,可以明确地构建用于Alpine的OpenJDK,因为有一些Alpine Docker容器的OpenJDK示例。在Ubuntu上进行针对Alpine的交叉编译也应该可以。但OpenJDK构建说明中有一个注意事项:"在Linux上构建OpenJDK通常不会有太多问题。唯一的一般建议是尽量使用由您的发行版提供的编译器、外部库和头文件。"如果在Ubuntu上构建的Java可执行文件出现问题,您可以尝试:- 在Alpine上进行构建,或- 在Ubuntu上安装Alpine的头文件和库,并在构建过程中使用它们而不是使用Ubuntu的头文件和库。如果您正在使用Alpine的头文件等进行交叉编译,您还应阅读构建说明中相应的部分,并了解--with-sysroot=...配置选项。 (如果您已经对C/C++编译原理有很好的理解,并具有使用gcc和configure工具链的经验,将有所帮助。OpenJDK构建说明假定您具有这方面的知识。)

英文:

> Is it feasible to build jdk for Alpine from Ubuntu?

Firstly, it is clearly feasible to build OpenJDK for Alpine, because there are examples of Alpine Docker containers for OpenJDK.

Cross-compiling on Ubuntu for Alpine should also work. But there is a caveat in the OpenJDK Build instructions:

> "It is often not much problem to build OpenJDK on Linux. The only general advice is to try to use the compilers, external libraries and header files as provided by your distribution."

If you are having problems getting the Java executables you built on Ubuntu to work you could try:

  • building on Alpine itself, or
  • installing the Alpine headers and libraries on your Ubuntu box and using them in your build rather than the Ubuntu headers and libraries.

If you are cross compiling using the Alpine headers etc, you should also read the corresponding section on the build instructions. And read about the --with-sysroot=... configuration option.

(It would help if you already have a good understanding of how C / C++ compilation works, and experience with using the gcc and configure tool-chains. The OpenJDK build instructions assume this.)

huangapple
  • 本文由 发表于 2023年5月13日 23:28:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76243531.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定