0

I have a VS12 project and exposed some of the classes to Python using boost-python. After some linkage issues my project finally builds correctly and generates a MySDK.lib and MySDK.dll. I called the Boost Python module the same as the library i.e. BOOST_PYTHON_MODULE(MySDK). Are these .lib and .dll all I need to use MySDK from Python?

I'm using Pycharm Community but can't find a way to import the generated MySDK.lib and MySDK.dll as a Python library module.

Saddly there isn't much information of what to do after the Boost Python coding exercise.

4
  • This question suggests a similar probelm: stackoverflow.com/questions/27842074/… Can you make yours work outside PyCharm? Commented Dec 12, 2016 at 16:24
  • Actualy it is worse than that. After adding the lib and dll locations to my Path variable. I go to the command line run the python interpreter and this is what I get: ImportError: No module named MySDK Commented Dec 12, 2016 at 16:29
  • Inside PyCharm or not? Commented Dec 12, 2016 at 17:08
  • @doctorlove all good now thank you! Commented Dec 12, 2016 at 19:06

1 Answer 1

1

I changed my VS12 project output file extension to .pyd (Right Click on Project -> Properties -> Linker -> General -> Output File -> changed to $(OutDir)$(TargetName).pyd) and now I can load the library in Python from the command line but still can't from Pycharm.

After that, made the directory where the .pyd (along with .lib and .dll) is located under the Path variable. Then Pycharm is able to successfully load and run my custom boost-python library.

UPDATE The pyd that Python understands and can load is simply the dll renamed to pyd. Therefore, an even cleaner way is to leave the VS12 project as is generating the original $(OutDir)$(TargetName)$(TargetExt) i.e. dll output and simply add a Post-Build Event that copies the dll into a pyd:

(Right Click on Project -> Properties -> Configuration Properties -> Build Events -> Post-Build Event -> Command Line) and add copy $(OutDir)$(TargetName)$(TargetExt) $(OutDir)$(TargetName).pyd

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.