Skip to content

Building NB_MODULE with enum dependency #366

Closed Answered by wjakob
mthramann asked this question in Q&A
Discussion options

You must be logged in to vote

This is a bit of an unusual setup. The traditional way would be to have your library (mylib) contain project code which is not related to the Python bindings. The python bindings import this library and expose the contained functionality.

The problem in your case is that you are linking libnanobind twice. Once as a shared library, and once as a static one. The shared version linked by these lines

nanobind_build_library(nanobind)
target_link_libraries(mylib PRIVATE nanobind)

is never properly initialized, and a lookup for internal data structures eventually crashes when a pointer is NULL. The easy fix is to add NB_SHARED to the nanobind_add_module call. Then both use the same library, and…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mthramann
Comment options

Answer selected by mthramann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants