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* 

然后再编译,顺利通过。

相关推荐
一棵树长得超出它自己11 分钟前
Allure安装与使用【macOS】
macos
三金C_C1 小时前
Mac配置开发环境
macos·开发环境
阿7_QuQ12 小时前
Mac屏幕共享怎么使用?
运维·服务器·macos
Doris Liu.1 天前
macOS取证分析——Safari浏览器、Apple Mail数据和Recents数据库
数据库·macos·缓存·sqlite·safari·电子数据取证·macos取证
Brian_Lucky1 天前
macOS安装未验证软件报错解决:以FinalShell为例的完整指南
macos
yzwdzkn1 天前
解决Flutter 2.10.5在升级Xcode 16后的各种报错
flutter·macos·xcode
Unlimitedz1 天前
iOS内存管理中的强引用问题
macos·ios·cocoa
一直在学习的小白~1 天前
关于MacOS使用Homebrew的详细介绍
macos
weixin_350570641 天前
为啥mac日历打不开浏览器
macos
半糖土豆爱编码_1 天前
【mysql】Mac 通过 brew 安装 mysql 、启动以及密码设置
数据库·mysql·macos