Reputation: 3
I simply pass a pyarrow.Table
to C++
arrow::Table
, and then passed back to python. But failed with:
trade.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZNK5arrow6Status8ToStringB5cxx11Ev
I have done some investigation and suspect that there is an issue of pyarrow_wrap_table
, but don't know how to fix it. Your help would be very much apprecated!
Here are source files:
file: table_func.h
#ifndef TABLE_FUNC_H
#define TABLE_FUNC_H
#include <vector>
#include <exception>
#include <arrow/api.h>
#include <arrow/result.h>
#include <memory>
namespace MktData
{
std::shared_ptr<arrow::Table> aggregateTradeTable(const std::shared_ptr<arrow::Table> &);
};
file: table_func.cpp
std::shared_ptr<arrow::Table> MktData::aggregateTradeTable(const std::shared_ptr<arrow::Table> &trades)
{
return trades;
}
file: decl.pxd
# distutils: language = c++
from pyarrow.lib cimport *
cdef extern from "table_func.h" namespace "MktData":
cdef shared_ptr[CTable] aggregateTradeTable(shared_ptr[CTable] &);
file: trade.pyx
from libcpp cimport bool, vector, memory
from pyarrow.lib cimport *
from decl cimport aggregateTradeTable
def aggregate_trades(obj):
cdef shared_ptr[CTable] trades = pyarrow_unwrap_table(obj)
if trades.get() == NULL:
raise TypeError("not an table")
cdef shared_ptr[CTable] result = aggregateTradeTable(trades)
if result.get() == NULL:
raise TypeError("result incorrect")
return pyarrow_wrap_table(result)
file: setup.py
from setuptools import setup
from Cython.Build import cythonize
from setuptools import Extension, setup
import pyarrow as pa
import numpy as np
sourcefiles = ['trade.pyx', 'table_func.cpp']
extensions = [Extension("trade", sourcefiles)]
ext_modules = cythonize(extensions, gdb_debug=True)
for ext in ext_modules:
ext.include_dirs.append(pa.get_include())
ext.include_dirs.append(np.get_include())
ext.libraries.extend(pa.get_libraries())
ext.library_dirs.extend(pa.get_library_dirs())
setup(ext_modules=ext_modules, language="c++")
Upvotes: 0
Views: 318
Reputation: 21
problem solved by
file: setup.py
...
for ext in ext_modules:
...
ext.define_macros.append(("_GLIBCXX_USE_CXX11_ABI", "0"))
Upvotes: 2