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* 

然后再编译,顺利通过。

相关推荐
SoraLuna4 小时前
「Mac畅玩AIGC与多模态40」开发篇35 - 用 Python 开发服务对接 SearxNG 与本地知识库
python·macos·aigc
WuYiCheng66610 小时前
TLS 1.3黑魔法:从协议破解到极致性能调优
macos
piaoxue82012 小时前
Mac上安装运行SynthTIGER
macos·语言模型
小山菌13 小时前
mac中加载C++动态库文件
开发语言·c++·macos
THMAIL15 小时前
mac M芯片运行docker-desktop异常问题
macos·docker·容器
laocooon52385788620 小时前
一台入网的电脑有6要素, 机器名,mac,ip,俺码,网关,dns,分别有什么作用
网络协议·tcp/ip·macos
德亦周1 天前
如何在Mac电脑上的VScode去配置C/C++环境
c++·vscode·macos
tonngw2 天前
【Mac 从 0 到 1 保姆级配置教程 12】- 安装配置万能的编辑器 VSCode 以及常用插件
git·vscode·后端·macos·开源·编辑器·github
亚林瓜子2 天前
虚拟Python 环境构建器virtualenv安装(macOS版)
python·macos·virtualenv·pipx
瓜子三百克2 天前
采用sherpa-onnx 实现 ios语音唤起的调研
macos·ios·cocoa