0

I wrote a package in C++ using C++ initialization of global variables, and built it into a .so shared library. I imported it into Python successfully using ctypes (on Mac). But the moment I tried to run a function, it crashed, because variables were uninitialized because the initialization code had not been run. I know that C++ creates one or more functions to be the initialization sequence, but when I used nm -g on my library I couldn't see them. (I know what they look like in Windows libraries, but the format seems to be different on Mac.)

Does anybody know how to find and run the C++ initialization stuff?

Joymaker
  • 813
  • 1
  • 9
  • 23
  • It is probably quite difficult if possible at all, see http://stackoverflow.com/questions/1615813/how-to-use-c-classes-with-ctypes – J.J. Hakala Jan 20 '16 at 04:29
  • Given this, I looked into Cython and I will probably find it useful for some purposes down the road. Looks like it would do the job. But for the moment, I decided the most fruitful approach was to convert my entire app into C++, abandoning Python entirely. This solves some Python version compatibility problems I was having, as well as major speed problems, as well as access to the C++ library. – Joymaker Jan 21 '16 at 19:42

0 Answers0