Working on a code that enables Python to call a C++ code compiled into shared library file (.so
file) via Python's ctypes
module, using the standard ctypes.CDLL
method. The C++ code performs the numerical calculations and the Python code mainly serves as a controller and performs data analysis. Everything worked fine. However, as soon as I included jsoncpp
library in C++ code, Python started to complain about undefined symbol errors such as undefined symbol: _ZN4Json5ValueaSES0_
etc. I used jsoncpp
library in C++ mainly to export data to a JSON file. Having searched the internet for a while, it appears this hasn't been discussed that much. Any idea how to handle this?
Well, looks like the solution is to also include -ljsoncpp
flag while compiling towards the shared .so
file:
$(CC) -shared -o testcode.so testcode.o -ljsoncpp