Closed JiauZhang closed 3 weeks ago
I defined an class with static class member, and I can successfully compile the code, but there are problems when import it
$ python -c "import _C" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: /mnt/d/code/nnops/build/_C.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZN6Device8devices_E
The main branch can reproduce this error: https://github.com/JiauZhang/nnops/tree/main
# build and test git clone https://github.com/JiauZhang/nnops cd nnops mkdir build && cd build && cmake .. && make python -c "import _C"
If I define this static class member https://github.com/JiauZhang/nnops/blob/main/csrc/device.h#L23 at .cpp file, everything is OK. The corresponding code is on branch fix: https://github.com/JiauZhang/nnops/tree/fix
commit diff: https://github.com/JiauZhang/nnops/commit/3a0db85f833c9de21da4943ea1b2624f1a7719f8
No response
This is a C++ linking issue that isn't related to nanobind.
Problem description
I defined an class with static class member, and I can successfully compile the code, but there are problems when import it
The main branch can reproduce this error: https://github.com/JiauZhang/nnops/tree/main
If I define this static class member https://github.com/JiauZhang/nnops/blob/main/csrc/device.h#L23 at .cpp file, everything is OK. The corresponding code is on branch fix: https://github.com/JiauZhang/nnops/tree/fix
commit diff: https://github.com/JiauZhang/nnops/commit/3a0db85f833c9de21da4943ea1b2624f1a7719f8
Reproducible example code
No response