You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C++20中Apache Arrow Flight SQL 19编译报错:FlightEndpoint类型不完整

Apache Arrow Flight SQL 19 编译错误:FlightEndpoint 不完整类型问题

在C++20项目中使用Apache Arrow Flight SQL 19时,只要引入<arrow/flight/api.h>头文件,就会触发多个关于arrow::flight::FlightEndpoint是不完整类型的编译错误。

错误信息

FAILED: src/utility/server/CMakeFiles/serverLib.dir/StatementHandler.cpp.o 
/usr/bin/clang++-20 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/llvm-20/include -I/lingo-db/include -I/lingo-db/vendored -I/lingo-db/build/lingodb-release/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=gnu++20 -fvisibility=hidden   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MD -MT src/utility/server/CMakeFiles/serverLib.dir/StatementHandler.cpp.o -MF src/utility/server/CMakeFiles/serverLib.dir/StatementHandler.cpp.o.d -o src/utility/server/CMakeFiles/serverLib.dir/StatementHandler.cpp.o -c /lingo-db/src/utility/server/StatementHandler.cpp
In file included from /lingo-db/src/utility/server/StatementHandler.cpp:7:
In file included from /usr/include/arrow/api.h:22:
In file included from /usr/include/arrow/array.h:41:
In file included from /usr/include/arrow/array/array_base.h:24:
In file included from /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/vector:66:
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:370:35: error: arithmetic on a pointer to an incomplete type 'arrow::flight::FlightEndpoint'
  370 |                       _M_impl._M_end_of_storage - _M_impl._M_start);

CMake配置

find_package(Arrow 19 REQUIRED)
find_package(ArrowFlight 19 REQUIRED)
find_package(ArrowFlightSql 19 REQUIRED)

add_library(serverLib OBJECT StatementHandler.cpp)
target_link_libraries(serverLib PRIVATE Arrow::arrow_static PRIVATE ArrowFlight::arrow_flight_static PRIVATE ArrowFlightSql::arrow_flight_sql_static)

触发错误的最简代码

#include <arrow/api.h>
#include <arrow/flight/api.h>

已尝试的解决方法

  • 改用共享库而非静态链接
  • 更换不同的Arrow版本
  • 先引入<arrow/flight/types.h>头文件

解决方案

这个问题源于头文件包含顺序错误,以及静态库编译时的符号可见性配置冲突,可按以下方式修复:

  1. 调换头文件包含顺序
    先引入<arrow/flight/api.h>再引入<arrow/api.h>,确保FlightEndpoint类型在标准库容器(如std::vector)实例化前被完整定义:

    #include <arrow/flight/api.h>
    #include <arrow/api.h>
    
  2. 优化CMake链接配置
    简化target_link_libraries的写法,确保依赖库的传递性正确:

    target_link_libraries(serverLib PRIVATE 
      Arrow::arrow_static 
      ArrowFlight::arrow_flight_static 
      ArrowFlightSql::arrow_flight_sql_static
    )
    
  3. 添加静态库编译宏
    针对静态库编译,显式定义ARROW_FLIGHT_EXPORT为空,避免符号导出逻辑导致的类型隐藏:

    target_compile_definitions(serverLib PRIVATE ARROW_FLIGHT_EXPORT=)
    
  4. 统一编译器版本
    避免混合使用clang++-20和GCC 13的标准库,建议使用同一套编译器工具链编译项目和Arrow库,减少C++20特性的实现差异问题。

如果问题依旧,检查Arrow库的编译参数,确认编译静态库时已启用ARROW_FLIGHT和ARROW_FLIGHT_SQL模块,且未设置会隐藏类型定义的编译选项(如-fvisibility=hidden在静态库中的不当使用)。

内容的提问来源于stack exchange,提问作者mor15euro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 05:53:13