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 best solutions below
Related Questions in BUILD
- Ionic cordova build
- Force GHC using local files
- RPM spec files with rpmbuild can have errors
- (automake, libtool) build fails in automake when using same source file name in different directory
- Backup strategy for build tool hosted on Azure VM
- include typescript file in output result build with TFS
- Android Build failed at ':app:dexDebug' with exception ( library and app project )
- GNU make - depend only on file existence and not modification time
- Error code 31 returned from mt.exe when building C++ projects in Visual Studio 2013
- IONIC FRAMEWORK Build Xcode Error :(
- Jenkins - Stage before "Source Code Management"
- Python: Trouble with dill installation
- Execution failed for task 'app:mergeDebugResources' Crunching Cruncher....png failed
- Android: Execution failed for task ':app:processDebugResources'
- Change assets urls to cdn adding absolute path in Grunt
Related Questions in SHARED-LIBRARIES
- Global variable in shared library
- How to load all symbols from shared library on start up?
- What happens when ld link different versions of the same library
- MapReduce job fails with ExitCodeException exitCode=255
- Android NDK - Including prebuilt static libraries gives undefined reference errors
- Detecting unresolved symbols in an ELF executable
- How to structure Xamarin library containing iOS & Android bindings?
- How do I share headers and libraries in subdirectory by cmake?
- Using 32-bit library from 64-bit application with perl or neko
- about Multiple dex files define Lcom/google/gson/JsonSerializer
- How do I install the Matlab MCR in Ubuntu 14.04 without "killing" Unity?
- How do Linux programs know where the library files are and how to call them?
- Linux ELF - Why does normal linking run faster than 'ldd -r'?
- How to include a "custom" library in Code::Blocks? (Windows 7)
- Error Linking OpenCV Libraries
Related Questions in BAZEL
- Tensorflow add a new op, could not import from python
- Compile OpenSSL for Android with Bazel
- Uncertain how to run Bazel: Tensorflow Inception Retrain New Categories Tutorial Python
- building a tensorflow based android app with tensorflow as a repository
- How to create a CRON job which runs a bazel command
- Errors when trying to build label_image neural net with bazel
- how to use clang++ instead g++ in Bazel
- tensorflow model im2txt: error when using Bazel build "couldn't determine target from filename"
- can not get APK through bazel build in tensorflow
- syntaxnet ./configure error
- everytime my Ubuntu is rebooted, Tensorflow with GPU support needs to be rebuild
- Sending specific compilation flags for static compilation with Bazel Build
- Setting targetSdkVersion and compileSdkVersion for bazel, android tensorflow
- What is the right way to refer bazel data files in python?
- Compiling a custom TensorFlow operation outside TF source tree
Related Questions in CPPYY
- Error in cmd whlie installing CPPYY on windows
- Pointer Variable raise error as unknown type when using cppyy in python
- Is there *any* solution to packaging a python app that uses cppyy?
- How should I control the lifetime of a python callable from c++?
- cppyy cling fails on class member initialization if =default constructor was declared
- cppyy - trouble converting to MYMODEL*&
- Exception at `import cppyy` on macOS Catalina or Big Sur
- Unable to import cppyy in Pyhon
- cppyy unable to open shared library
- Cppyy cmake build cannot find libclang
- How do I call a function with an std::ostream& argument using cppyy?
- SIGSEGV on doing "import cppyy"
- cppyy.ll.cast fails to cast char*
- How to call function/classes in c++ .so files, generated by Bazel, in Python?
- How to install python modules using cppyy?
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)
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?
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).