简体   繁体   中英

Confusion wrapping c++ library to python

I have a .cpp and .h source file pair which is a manager (I guess a wrapper also) for a c++ library I have made. I want to let people use this manager to work with my library in python. I have heard about several different ways to wrap this library into python like cython and boost.python but Im having trouble with understanding the process.

If I want to make this manager usable in python, do I need to wrap it in a different way for each version of python? (2.7 vs 3.4) Do I also need to wrap it in a different way for each operating system for each version? So 2.7/3.4 for Windows vs 2.7/3.4 for Linux?

Concerning your confusion about the process, just follow any tutorial for any of the wrapper libs you found or where suggested in the comments.

If I want to make this manager usable in python, do I need to wrap it in a different way for each version of python? (2.7 vs 3.4)

Yes. You might be able to load binary modules compiled for Python 3.4 into Python 3.5, but it's unlikely to work across major versions.

Do I also need to wrap it in a different way for each operating system for each version?

Yes. Just as you need to compile your C++ code for different operating systems (and possibly versions) and CPU architectures, Python modules are not different. However, the "wrap it in a different way" just means "compile for the target environment".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM