Java 如何构建OpenJDK 8 src.zip/launcher的C代码/

Java 如何构建OpenJDK 8 src.zip/launcher的C代码/,java,openjdk,Java,Openjdk,我已经下载了JDK 8.20: 其中有一个src.zip,它看起来像一个嵌入示例,但没有makefile或其他构建脚本 目录/launcher/包含以下文件: defines.h emessages.h java.c java.h java_md.h java_md_common.c java_md_solinux.c java_md_solinux.h jli_util.c jli_util.h main.c manifest_info.h parse_manifest.c splashscr

我已经下载了JDK 8.20:

其中有一个src.zip,它看起来像一个嵌入示例,但没有makefile或其他构建脚本

目录/launcher/包含以下文件:

defines.h
emessages.h
java.c
java.h
java_md.h
java_md_common.c
java_md_solinux.c
java_md_solinux.h
jli_util.c
jli_util.h
main.c
manifest_info.h
parse_manifest.c
splashscreen.h
splashscreen_stubs.c
version_comp.c
version_comp.h
wildcard.c
wildcard.h
我制作了这个小build.sh脚本:

# -m32 = 32bit for embedding
# -I. for fake jvm.h, because it does not exist and fails on including it otherwise
options="-m32 -I/root/openjdk8/jdk1.8.0_20/include/ -I/root/openjdk8/jdk1.8.0_20/include/linux/ -I."

echo "COMPILE java.c"
gcc -c java.c -o java.o $options

echo "COMPILE java_md_common.c"
gcc -c java_md_common.c -o java_md_common.o $options

echo "COMPILE java_md_solinux.c"
gcc -c java_md_solinux.c -o java_md_solinux.o $options

echo "COMPILE jli_util.c"
gcc -c jli_util.c -o jli_util.o $options

echo "COMPILE main.c"
gcc -c main.c -o main.o $options

echo "COMPILE parse_manifest.c"
gcc -c parse_manifest.c -o parse_manifest.o $options

echo "COMPILE splashscreen_stubs.c"
gcc -c splashscreen_stubs.c -o splashscreen_stubs.o $options

echo "COMPILE version_comp.c"
gcc -c version_comp.c -o version_comp.o $options

echo "COMPILE wildcard.c"
gcc -c wildcard.c -o wildcard.o $options
出现以下错误:

./build.sh
COMPILE java.c
java.c: In function âContinueInNewThreadâ:
java.c:1885:29: error: storage size of âargs1_1â isnât known
COMPILE java_md_common.c
java_md_common.c: In function âProgramExistsâ:
java_md_common.c:67:17: error: storage size of âsbâ isnât known
java_md_common.c:70:26: error: âS_IEXECâ undeclared (first use in this function)
java_md_common.c:70:26: note: each undeclared identifier is reported only once for each function it appears in
java_md_common.c: In function âJLI_ReportErrorMessageSysâ:
java_md_common.c:155:21: error: âerrnoâ undeclared (first use in this function)
java_md_common.c: In function âProcessDirâ:
java_md_common.c:214:5: error: unknown type name âDIRâ
java_md_common.c:222:15: warning: assignment makes pointer from integer without a cast [enabled by default]
java_md_common.c:226:17: warning: assignment makes pointer from integer without a cast [enabled by default]
java_md_common.c:228:18: error: dereferencing pointer to incomplete type
java_md_common.c:229:18: error: dereferencing pointer to incomplete type
java_md_common.c:231:22: error: dereferencing pointer to incomplete type
java_md_common.c:233:22: error: dereferencing pointer to incomplete type
java_md_common.c:236:46: error: dereferencing pointer to incomplete type
java_md_common.c:237:67: error: dereferencing pointer to incomplete type
java_md_common.c:239:25: error: dereferencing pointer to incomplete type
java_md_common.c:242:48: error: dereferencing pointer to incomplete type
java_md_common.c: In function âFindBootStrapClassâ:
java_md_common.c:494:59: error: âRTLD_DEFAULTâ undeclared (first use in this function)
COMPILE java_md_solinux.c
java_md_solinux.c:27:20: fatal error: jvm_md.h: No such file or directory
compilation terminated.
COMPILE jli_util.c
COMPILE main.c
In file included from main.c:33:0:
defines.h:37:2: error: #error "FULL_VERSION must be defined"
defines.h:44:2: error: #error "JDK_MAJOR_VERSION and JDK_MINOR_VERSION must be defined"
main.c: In function âmainâ:
main.c:128:20: error: âFULL_VERSIONâ undeclared (first use in this function)
main.c:128:20: note: each undeclared identifier is reported only once for each function it appears in
main.c:129:20: error: âDOT_VERSIONâ undeclared (first use in this function)
COMPILE parse_manifest.c
COMPILE splashscreen_stubs.c
COMPILE version_comp.c
COMPILE wildcard.c

有人知道如何编译吗?

我目前面临着同样的问题。也许可以通过为您的设置提供jvm.h和jvm_md.h来解决这个问题。 两者都包含特定于jvm的符号,jvm_md.h还包含其他依赖于平台的符号。因此,您需要为目标jvm选择jvm.h,为目标平台选择jvm_md.h。要获取Oracle的OpenJDK8的这些头文件,请转到并下载源文件。(对于Java 7,它是等)

在这个文件中,您将在文件夹中找到jvm.h /openjdk/jdk/src/share/javavm/export/

jvm_md.h位于以下文件夹中: /openjdk/jdk/src/[目标平台]/javavm/export/

请注意,Linux和Bsd不存在此路径(/openjdk/jdk/src/[target platform]在这些情况下仅包含文档)。然而,我相信Solaris版本也是为这些系统服务的

希望这有助于