kmsxx icon indicating copy to clipboard operation
kmsxx copied to clipboard

init_pykmstest is called but undefined if utils option is not enabled

Open cshaw-velo-ai opened this issue 2 years ago • 3 comments

Hi, I'm building with python bindings turned on, but the utils option is turned off. This seems to lead to an undefined symbol in pykms.so:

>>> import pykms
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/site-packages/pykms/__init__.py", line 1, in <module>
ImportError: /usr/lib/python3.10/site-packages/pykms/pykms.so: undefined symbol: _Z14init_pykmstestRN8pybind117module_E

Looking at the code, init_pykmstest is called no matter what: https://github.com/tomba/kmsxx/blob/9c3df5f4391ce0743fc1f27b8e6c2af06bf282f7/py/pykms/pykms.cpp#L21

But the implementation of the function in pykmsutil.cpp is only included in the build if the tests option is enabled: https://github.com/tomba/kmsxx/blob/9c3df5f4391ce0743fc1f27b8e6c2af06bf282f7/py/pykms/meson.build#L19-L23

cshaw-velo-ai avatar Dec 19 '22 20:12 cshaw-velo-ai

Thanks. Can you try the master branch and see if it works for you now?

tomba avatar Dec 20 '22 07:12 tomba

I think this could work, but I'm not sure if it's what you want? It seems a bit weird since there are two meson options (utils and libutils). libutils is responsible for defining HAS_KMSXXUTIL which is what causes pykms to try to call init_pykmsutils, but pykmsutil.cpp is only included based on the utils option. I think what you want is to change pykms/meson.build so that pykmsutil.cpp is included based on the libutils options instead of the utils option?

cshaw-velo-ai avatar Dec 22 '22 16:12 cshaw-velo-ai

Ah, I was hasty, and didn't notice that the current meson.build uses 'utils'. That's obviously wrong. I'll look at this again later. And I see #69, so I should perhaps split the py bindings to two separate py modules, the core (depends on kms++) and the rest (depends on kms++utils).

tomba avatar Dec 22 '22 20:12 tomba