I wanted to use the macro cppyy_add_bindings from FindCppyy.cmake. I have to add this in a cpp/python using bazel project. How do I handle the library dependencies? Do I have to load all libraries explicitly in the py file, or is it possible to have bazel do this for me?
cmake to bazel - cppyy - shared libraries and includepath
623 views Asked by user9092688 At
1
There are 1 answers
Related Questions in BUILD
- Build issue in my STM32-NUCLEO project using the Eclipse IDE
- Module not found when building flutter app for IOS
- Why am I getting this error ? error CS0103: The name 'EnhancedStackTrace' does not exist in the current context
- Gradle 8.7 cannot find installed JDK 22 in IntelliJ
- Build LLVM, Clang and Libfuzzer
- when I open a ktor project, error Cannot invoke "java.nio.file.Path.toString()" because the return value of "java.nio.file.Path.getFileName()" is null
- Cannot make Django run the frontend from Vite's build ("was blocked because of a disallowed MIME type (“text/html”)")
- Distorted CSS after Build process
- how to build nextjs app unable to build and deploy
- How to build custom mediapipe python model i.e. adding flow_limiter_calculator to face_landmark_front_cpu.binarypb
- Assets not showing after build process in Vite and React
- "Config.guess failed to determine the host type" when trying build binutils-2.7 with Cygwin
- The assembled Python application does not launch
- Why rebuild module does not recompile dependency module, but build module does in IntelliJ Idea?
- Gitlab pipeline stuck with nx cloud issue
Related Questions in SHARED-LIBRARIES
- Keep multi-version of a static-lib like what we do for shared-libs
- Link shared library through makefile
- how to test .dll on Linux
- installing 'xiaomi notes.apk' through adb on chromebook getting error
- bazel 6.5.0 build: failing to link external non-bazel shared library
- can't reference netstandard2.0 library if a reference to CodeAnalysis.CSharp is present
- HDF5 Library: Works for Running Binary but Fails to Recompile — Why?
- How to resolve the shared library of a function in core file, using GDB - when no symbols are loaded?
- How to use "APP_INITIALIZER" into a library with standalone components
- Use Conan to manage runtime dependencies
- Defining a Global Variable from Library Object
- The problem with explicitly linking the library
- The problem with the explicit dynamic library
- Linux: how can I force my process to free unloaded libraries?
- LoadLibrary error while using libtorch with ROS2
Related Questions in BAZEL
- How to build custom mediapipe python model i.e. adding flow_limiter_calculator to face_landmark_front_cpu.binarypb
- How to save compilation progress using Bazel
- How to list all test names which were executed during `bazel test` command - even passing ones
- How do I build my project with Meson or Bazel when I want to use Folly as a dependency?
- Getting missing strict dependencies error when trying to build with Bazel
- Bazel build including header failing
- bazel 6.5.0 build: failing to link external non-bazel shared library
- How to Access Nested Directory Files in Bazel Go Test Environment?
- Bazel cross platform build fails with "Unable to find a CC toolchain using toolchain resolution."
- Lombok AnnotationProcessor failing with Bazel build
- How to decorate bazel test output to include github actions groups?
- Install tink library for Python on Windows
- How to run multiple Bazel Query operations in parallel?
- Bazel build part of third party library as static library with headers
- How do you build a Rust Wasm binary with Bazel?
Related Questions in CPPYY
- CMAKE Build error while building cppyy from source
- cppyy - trouble converting to MYMODEL*&
- cppyy cling fails on class member initialization if =default constructor was declared
- How should I control the lifetime of a python callable from c++?
- Cppyy Setting a referenced value
- converting cppyy returned objects to python objects
- Trouble using cppyy to run c++ code that connects to a RabbitMQ instance with SSL connection
- Unable to install cppyy on Ubuntu — gmake error 2
- cppyy crash with uint8_t arrays
- Initializing std::map of pointers of objects in cppyy
- Cppyy map of subclassed or templated objects
- Using cppyy with rvalue pointers and maps
- Cppyy pythonization with templates?
- How to define in Python a shared pointer to imported virtual class using cppyy
- How do I call a function with an std::ostream& argument using cppyy?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
I'm not familiar with Bazel, but can perhaps shed some light of what cppyy needs/expects. In particular, FindCppyy.cmake was written with a specific type of use in mind that may not fit everyone.
What cppyy needs is for the linker symbols of C++ code used from Python to be available at run-time. How they are made available does not matter: as long as they are, it will work. Here are a couple of options:
Link dependent libraries with another library that will be loaded. This is typical when using dictionaries (https://cppyy.readthedocs.io/en/latest/utilities.html#dictionaries): simply link all the relevant library with the dictionary shared library, then only load the dictionary, the rest will be pulled in by the dynamic linker. This is the most common method AFAIK, precisely b/c the dependencies are easy to figure out as the build tool already has them and already knows how to link.
Add them to the .rootmap file (https://cppyy.readthedocs.io/en/latest/utilities.html#class-loader): when a class is not found, the .rootmap files (which should sit in some path reachable by
LD_LIBRARY_PATHon Linux/Mac orPATHon Windows) are searched and if the class is found there, the libraries specified are all loaded. This would have my preference (b/c class-lazy, not project-lazy) and is often used together with a dictionary file as above.Use
cppyy.load_libraryexplicitly within a Python module. Personally, I do not prefer this unless the code is truly well compartimentalized, and/or the project is small (a handful of libraries at most), as this approach is not lazy.Use another means such as
ctypes.CDLL. This will work, butctypes.CDLLbehaves very differently from one OS to the next, putting more work on the developer, so I would not recommend it. It is also not lazy.The cppyy cmake macros mentioned assume that the goal is one python module per project, and that as laziness granularity, the project (as opposed to individual classes) is good enough. If that fits your purposes, that I'd go for the first option above: generate a dictionary from all headers for (each part of) the project, and get the list of libraries for it from Bazel, then when building the generated dictionary code, simply link with it. Finally, rely on auto-loading, or simply
load_librarythat one dictionary shared library.Now, if I take your question completely literally (don't know whether I should), then there may be an option for Bazel to load libraries explicitly into the process, e.g. startup? If so, that would work as long as the libraries are loaded with the
RTLD_GLOBALflag (Linux, Mac; this is common), or have the relevant symbols exported (Windows; also common, but requires more care).