Macos编译openjdk因berkeley-db版本问题失败解决办法

brew install openjdk

最后编译失败,报错如下:

* For target support_native_jdk.hotspot.agent_libsaproc_symtab.o:

/private/tmp/openjdk-20250203-10040-wpec6/jdk23u-jdk-23.0.2-ga/src/jdk.hotspot.agent/macosx/native/libsaproc/symtab.c:69:67: error: too few arguments to function call, expected 5, have 4

(*symtab->hash_table->put)(symtab->hash_table, &key, &value, 0);

原因是berkeley-db最新的版本这个get的定义是多一个DB_TXN的参数,看名字是用于事务处理的。

头文件位于:

/usr/local/include/db.h

/usr//local/Cellar/berkeley-db/18.1.40_2/include/db.h

/*
 * Copyright (c) 1996, 2020 Oracle and/or its affiliates.  All rights reserved.
 *
 * See the file LICENSE for license information.
 *
 * $Id$
 *..

*/

一开始以为是版本低了,upgrade了一下没有解决,

后来找了一下xcode目录下,也有一个db.h

$ find /Applications/Xcode.app/Contents/Developer  -name "db.h"
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/db.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/db.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/db.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/db.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/db.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/db.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/db.h
(base) DanyMini:mybuild dany$ vi /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/db.h

打开看了一下,好像比较老的,

/*-
 * Copyright (c) 1990, 1993, 1994
 *      The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the University of
 *      California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *      @(#)db.h        8.7 (Berkeley) 6/16/94
 * $FreeBSD: src/include/db.h,v 1.5 2002/03/26 01:35:05 bde Exp $
 */

同时get这个函数看起来也刚好是只有四个参数,

        int (*get)(const struct __db *, const DBT *, DBT *, unsigned int);

看来是优先使用/usr/local下的头文件了, 简单处理一下,看起来brew也有多份,直接删除一下/usr/local下的db.h及相关的头文件

 rm  /usr/local/include/db.h
rm /usr/local/include/db_185.h 
rm /usr/local/include/db_cxx.h 
rm /usr/local/include/dbstl* 

然后再编译,顺利通过。

相关推荐
kcarly4 小时前
Mac电脑上最新的好用邮件软件比较
macos·免费软件·邮件app
会飞的爱迪生4 小时前
mac连接linux服务器
linux·服务器·macos
Mac技巧大咖17 小时前
Mac怎么彻底卸载软件,简单彻底的卸载方式
macos·mac怎么彻底卸载软件
kcarly1 天前
Mac上有哪些好用的开源粘贴板app
macos·粘贴板·开源app·好用的app
某公司摸鱼前端2 天前
本地部署DeepSeek教程(Mac版本)
macos·ai编程·ollama·deepseek·deepseek r1
会飞的爱迪生2 天前
mac安装wireshark
测试工具·macos·wireshark
追光天使3 天前
Mac M1 源码安装FFmpeg,开启enable-gpl 和 lib x264
macos·ffmpeg
会飞的爱迪生3 天前
mac和linux传输文件
linux·运维·macos
数据的世界014 天前
解决.NET程序通过网盘传到Linux和macOS不能运行的问题
linux·运维·服务器·macos