Open thedrow opened 6 years ago
Not yet, feel free to submit a pull request for it
I've been tinkering with Python bindings for this library. I'm getting an ImportError due to a missing symbol. This missing symbol also seems to be missing from libvelocypack.a
Here's the ImportError I'm getting:
ImportError: dlopen(/Users/.../Library/Caches/pypoetry/virtualenvs/velocypack-IZ9-pmhB-py3.11/lib/python3.11/site-packages/vpack.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace (__ZNK8arangodb10velocypack9SliceBaseINS0_5SliceES2_E15byteSizeDynamicEPKh)
If I run
nm -g build/libvelocypack.a | grep __ZNK8arangodb10velocypack9SliceBaseINS0_5SliceES2_E15byteSizeDynamicEPKh
I get nothing. Is there something obvious that I'm missing?
If it's useful to you, I can fork and open a PR with what I've got so far.
Unfortunately I don't know much about Python bindings and how to create them.
So I can't really tell where this ImportError
comes from.
I tried creating a small test program and linking it to libvelocypack.a
, in order to see if there are any errors related to missing symbols or linking.
I have used the current state of the main
branch. Here's my test program (test.cpp):
#include <velocypack/Slice.h>
#include <velocypack/Builder.h>
#include <iostream>
int main() {
using namespace arangodb::velocypack;
Builder b;
b.openObject();
b.add("foo", Value("bar"));
b.close();
std::cout << b.slice().toJson() << ", " << b.slice().byteSize() << "\n";
}
I compiled & linked it with g++ (g++-11.4) via
g++ -std=c++20 -Wall -Iinclude -Lbuild test.cpp -lvelocypack
and executed it with ./a.out
.
All the steps worked fine for me.
I also tried building and linking with clang++-14 and it also worked fine.
So at least for me the generated libvelocypack.a
seems to be usable from external programs.
As mentioned before, I am not really aware of how Python bindings work, but do they actually supported using static libraries? Just wondering (random guess) if they may require using a dynamic library instead.
My understanding is limited as well, but the bindings file produced in this case is a .so
file. There is an extremely simple case that did work without bringing me this ImportError, but once I started expanding my Cython code, I hit this error. Maybe that's the clue to how I should continue. 🤔
Spent some time hacking around on it this morning and discovered that I have to define everything just so-so in Cython, or we are going to have a bad time. So much for remaining ignorant of advanced C++ templating in Cython.
Is there a Python binding to this library? If not, can we add one?