shared-libraries

Symbol not found using dlopen in Python

Symbol not found using dlopen in Python Question: I compiled BlockSci in macOS High Sierra 10.13.6. This created /usr/local/lib/libblocksci.dylib. I used pip3 to install the blocksci Python analysis library and this created /Users/${USER}/dev/BlockSci/blockscipy/blocksci/_blocksci.cpython-39-darwin.so. When I try to import the library via $ python3 hello.py: import blocksci It creates the following error in dlopen due to …

Total answers: 1

Export C++ function to python using ctypes: undefined symbol

Export C++ function to python using ctypes: undefined symbol Question: Consider this file containing two similar functions: #include <iostream> int main() { std::cout << “mainn”; } int notmain() { std::cout << “notmainn”; } I compiled this into a shared library: g++ -shared -Wl,-soname,code -o code.so -fPIC code.cpp I wish to call these from python, for …

Total answers: 2

Is it possible to compile library with waf using make install?

Is it possible to compile library with waf using make install? Question: I’m trying to compile a library with waf when I configure and build my project. To be more exact the library is Cryptopp. The thing is that I have added the source code like a git-submodule and I would like to compile and …

Total answers: 1

ctypes error: libdc1394 error: Failed to initialize libdc1394

ctypes error: libdc1394 error: Failed to initialize libdc1394 Question: I’m trying to compile my program to a shared library that I can use from within Python code using ctypes. The library compiles fine using this command: g++ -shared -Wl,-soname,mylib -O3 -o mylib.so -fPIC [files] `pkg-config –libs –cflags opencv` However, when I try and import it …

Total answers: 7

Importing from a relative path in Python

Importing from a relative path in Python Question: I have a folder for my client code, a folder for my server code, and a folder for code that is shared between them Proj/ Client/ Client.py Server/ Server.py Common/ __init__.py Common.py How do I import Common.py from Server.py and Client.py? Asked By: Drew || Source Answers: …

Total answers: 7

CMake output name for dynamic-loaded library?

CMake output name for dynamic-loaded library? Question: I’m trying to write cmake rules to build dynamic-loaded library for python using boost.python on linux. I’d like to use ‘foo’ for python module name. So, the library must be called foo.so. But by default, cmake uses standard rules for library naming, so if I write add_library(foo foo.cpp) …

Total answers: 2

Change current process environment's LD_LIBRARY_PATH

Change current process environment's LD_LIBRARY_PATH Question: Is it possible to change environment variables of current process? More specifically in a python script I want to change LD_LIBRARY_PATH so that on import of a module ‘x’ which depends on some xyz.so, xyz.so is taken from my given path in LD_LIBRARY_PATH is there any other way to …

Total answers: 5