当前位置: 首页 > news >正文

用DuckDB官方的步骤生成 1.4版插件的问题和解决

完全按照https://github.com/duckdb/extension-template 介绍的步骤,结果有一些问题。

  1. vcpkg/scripts/bootstrap.sh执行出错
    一开始是没装zip,
root@6ae32a5ffcde:/par/extension-template# sh ./vcpkg/scripts/bootstrap.sh -disableMetrics
Could not find zip. Please install it (and other dependencies) with:

装上就往下执行了,但是执行到第185行出错,

root@6ae32a5ffcde:/par/extension-template# apt install zip
Setting up zip (3.0-13) ...
root@6ae32a5ffcde:/par/extension-template# sh ./vcpkg/scripts/bootstrap.sh -disableMetrics
./vcpkg/scripts/bootstrap.sh: 185: .: cannot open //scripts/vcpkg-tool-metadata.txt: No such file

这个目录明显错误。
185行原文是
. "$vcpkgRootDir/scripts/vcpkg-tool-metadata.txt"
而在bootstrap.sh文件开头有计算vcpkgRootDir的代码,把它们都注释掉。

# Find .vcpkg-root.
#vcpkgRootDir=$(X= cd -- "$(dirname -- "$0")" && pwd -P)
#while [ "$vcpkgRootDir" != "/" ] && ! [ -e "$vcpkgRootDir/.vcpkg-root" ]; do
#    vcpkgRootDir="$(dirname "$vcpkgRootDir")"
#done

然后把vcpkgRootDir手工设置,就走下去了。

export vcpkgRootDir=/par/extension-template/vcpkg
root@6ae32a5ffcde:/par/extension-template# sh ./vcpkg/scripts/bootstrap.sh -disableMetrics
Downloading vcpkg-glibc...
vcpkg package management program version 2025-09-03-4580816534ed8fd9634ac83d46471440edd82dfeSee LICENSE.txt for license information.

2.make 执行出错

root@6ae32a5ffcde:/par/extension-template# export VCPKG_TOOLCHAIN_PATH=`pwd`/vcpkg/scripts/buildsystems/vcpkg.cmake
root@6ae32a5ffcde:/par/extension-template# make
mkdir -p build/release
cmake  -DEXTENSION_STATIC_BUILD=1  -DDUCKDB_EXTENSION_CONFIGS='/par/extension-template/extension_config.cmake'   -DOSX_BUILD_ARCH=   -DVCPKG_BUILD=1 -DCMAKE_TOOLCHAIN_FILE='/par/extension-template/vcpkg/scripts/buildsystems/vcpkg.cmake' -DDUCKDB_EXPLICIT_PLATFORM='' -DCUSTOM_LINKER= -DOVERRIDE_GIT_DESCRIBE="" -DUNITTEST_ROOT_DIRECTORY="/par/extension-template/" -DBENCHMARK_ROOT_DIRECTORY="/par/extension-template/" -DENABLE_UNITTEST_CPP_TESTS=FALSE -DBUILD_EXTENSION_TEST_DEPS=default  -DVCPKG_MANIFEST_DIR='/par/extension-template/' -DCMAKE_BUILD_TYPE=Release -S "./duckdb/" -B build/release
-- Found Python3: /usr/bin/python3 (found version "3.11.2") found components: Interpreter
CMake Error at /par/extension-template/vcpkg/scripts/buildsystems/vcpkg.cmake:943 (message):Could not find .vcpkg-root
Call Stack (most recent call first):/usr/share/cmake-3.25/Modules/CMakeDetermineSystem.cmake:124 (include)CMakeLists.txt:23 (project)

943行的内容如下

if(Z_VCPKG_HAS_FATAL_ERROR)message(FATAL_ERROR "${Z_VCPKG_FATAL_ERROR}")
endif()

再搜索错误提示Could not find .vcpkg-root,在403行找到

if(NOT Z_VCPKG_ROOT_DIR)z_vcpkg_add_fatal_error("Could not find .vcpkg-root")
endif()

还是找不到vcpkg根目录,在 403行前加入一行手工设置,set(Z_VCPKG_ROOT_DIR /par/extension-template/vcpkg),就又走下去了。

3.找不到ExtensionLoader类编译错误

[ 32%] Building CXX object src/main/extension/CMakeFiles/duckdb_generated_extension_loader.dir/__/__/__/codegen/src/generated_extension_loader.cpp.o
In file included from /par/extension-template/build/release/codegen/include/generated_extension_headers.hpp:4,from /par/extension-template/duckdb/src/include/duckdb/main/extension/generated_extension_loader.hpp:1,from /par/extension-template/build/release/codegen/src/generated_extension_loader.cpp:1:
/par/extension-template/src/include/quack_extension.hpp:9:19: error: 'ExtensionLoader' has not been declared9 |         void Load(ExtensionLoader &db) override;|                   ^~~~~~~~~~~~~~~
/par/extension-template/src/include/quack_extension.hpp:9:14: error: 'void duckdb::QuackExtension::Load(int&)' marked 'override', but does not override9 |         void Load(ExtensionLoader &db) override;|              ^~~~
In file included from /par/extension-template/duckdb/src/include/duckdb/main/extension/generated_extension_loader.hpp:1:
/par/extension-template/duckdb/src/include/duckdb/main/database.hpp: In instantiation of 'void duckdb::DuckDB::LoadStaticExtension() [with T = duckdb::QuackExtension]':
/par/extension-template/build/release/codegen/src/generated_extension_loader.cpp:9:45:   required from here9 |       db.LoadStaticExtension<QuackExtension>();|       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/par/extension-template/duckdb/src/include/duckdb/main/database.hpp:119:19: error: cannot declare variable 'extension' to be of abstract type 'duckdb::QuackExtension'119 |                 T extension;|                   ^~~~~~~~~
/par/extension-template/src/include/quack_extension.hpp:7:7: note:   because the following virtual functions are pure within 'duckdb::QuackExtension':7 | class QuackExtension : public Extension {|       ^~~~~~~~~~~~~~
In file included from /par/extension-template/duckdb/src/include/duckdb/main/database.hpp:14:
/par/extension-template/duckdb/src/include/duckdb/main/extension.hpp:22:33: note:     'virtual void duckdb::Extension::Load(duckdb::DuckDB&)'22 |         DUCKDB_API virtual void Load(DuckDB &db) = 0;|                                 ^~~~
/par/extension-template/duckdb/src/include/duckdb/main/database.hpp:123:31: error: cannot convert 'duckdb::DuckDB' to 'int&'123 |                 extension.Load(*this);|                 ~~~~~~~~~~~~~~^~~~~~~
/par/extension-template/src/include/quack_extension.hpp:9:36: note:   initializing argument 1 of 'void duckdb::QuackExtension::Load(int&)'9 |         void Load(ExtensionLoader &db) override;|                   ~~~~~~~~~~~~~~~~~^~
gmake[3]: *** [src/main/extension/CMakeFiles/duckdb_generated_extension_loader.dir/build.make:76: src/main/extension/CMakeFiles/duckdb_generated_extension_loader.dir/__/__/__/codegen/src/generated_extension_loader.cpp.o] Error 1
gmake[3]: Leaving directory '/par/extension-template/build/release'
gmake[2]: *** [CMakeFiles/Makefile2:6462: src/main/extension/CMakeFiles/duckdb_generated_extension_loader.dir/all] Error 2
gmake[2]: Leaving directory '/par/extension-template/build/release'
gmake[1]: *** [Makefile:136: all] Error 2
gmake[1]: Leaving directory '/par/extension-template/build/release'
make: *** [extension-ci-tools/makefiles/duckdb_extension.Makefile:161: release] Error 2
root@6ae32a5ffcde:/par/extension-template#

这个类是1.4版新引入的,我在自己用动态链接库编译时,动态链接库附带的duckdb.hpp中有它的声明,但是源代码中的duckdb.hpp只有如下5行

#pragma once#include "duckdb/main/connection.hpp"
#include "duckdb/main/database.hpp"
#include "duckdb/main/query_result.hpp"
#include "duckdb/main/appender.hpp"

一开始以为是git clone了错误版本,手工下载了1.4发行版的源代码压缩包,也是一样的,就没办法了。
官方的步骤这么多,生成速度又慢,从开始make到出错,大概几十分钟,等不起,这就是消除插件对动态库依赖的代价,如果要开发自己的插件,还是链接动态库好了。

http://www.dtcms.com/a/423683.html

相关文章:

  • 如何快速找到与课题相关的高质量文献?
  • 第三十八天:回文数组
  • 字体排版网站做动漫图片的网站
  • springboot个人博客系统的设计与实现(代码+数据库+LW)
  • 软件工程实验三-原型设计
  • Android开发-存储框架技术总结
  • 备案审核网站显示500爱做网站免费
  • 深圳做网站哪家公司比较好而且不贵弄一个网站要多少钱
  • 借助SFTTrainer进行微调 (109)
  • BeanFactory
  • Linux CentOS 7 安装 zip-3.0-11.el7.x86_64.rpm 详细步骤(命令行教程)​(附安装包)
  • VLM Prompt优化之 DynaPrompt(ICLR 2025)论文总结
  • 网站开发和网站制作的区别wordpress如何改成cms
  • 网站首页布局河北手机网站制作价格
  • 负载均衡式的在线OJ项目编写(六)
  • 中止 Web 请求新方式 - AbortController API
  • 做微商如何网站推广需要外包团队做网站怎么提需求
  • 在JavaScript / Node.js中,SQLite异步查询函数实现
  • 数据结构:Map 和 Set (二)
  • 服务网站安徽省建设厅网站备案
  • 从零到一构建现代化 C# 在线编程环境:SharpPad 技术架构深度解析
  • Golang指针的基本概念
  • WordPress提速指南:Memcached+Super Static Cache+CDN缓存网站内容
  • 辽宁手机版建站系统开发平面设计学徒
  • 福州做网站制作北京楼市暴跌
  • PG 中 .psqlrc 配置文件使用案例
  • Linux开发——中断
  • 【快乐数六】2022-11-21
  • redis单线程模型
  • 松江新桥网站建设东莞做网站首选企业铭