OpenJdk11编译时遇到‘readdir64_r’ is deprecated如何解决?
当自己下载OpenJDK源码并且编译时遇到报错:
Warning: No mercurial configuration present and no .src-rev
/data/JDKIntallZip/jdk11u-dev/jdk11/src/java.base/unix/native/libjava/TimeZone_md.c: In function ‘findZoneinfoFile’:
/data/JDKIntallZip/jdk11u-dev/jdk11/src/java.base/unix/native/libjava/TimeZone_md.c:150:5: error: ‘readdir64_r’ is deprecated [-Werror=deprecated-declarations]
while (readdir64_r(dirp, entry, &dp) == 0 && dp != NULL) {
^~~~~
In file included from /data/JDKIntallZip/jdk11u-dev/jdk11/src/java.base/unix/native/libjava/TimeZone_md.c:36:0:
/usr/include/dirent.h:201:12: note: declared here
extern int readdir64_r (DIR *__restrict __dirp,
^~~~~~~~~~~
cc1: all warnings being treated as errors
解决的方法:在执行configure时增加如下参数,即可。
# bash configure --enable-debug --with-jvm-variants=server --enable-dtrace --disable-ccache --with-extra-cflags="-Wno-error=deprecated-declarations"