The Dll Created By Boost.python Cannot Be Imported (following Boost Python's Quickstart)
Solution 1:
I solved the problem myself. Thank jagerman for his useful suggestions.
(1) Just change the output filename from ConsoleApplication1.dll to hello_ext.pyd. You can automate this rename by setting Pages->General->Target Extension to ".pyd". Make sure the file hello_ext.pyd is in python's search path. You can just throw it to C:\Python27\DLLs which is one of python's built-in search paths.
(2) Now you will got a different import error: DLL load failed: The specified module could not be found. If you look closely at the file size of hello_ext.pyd, you'll likely notice something wired -- it's only 19KB. That means it doesn't contain everything needed to import into python, so python has to find the missing part to properly import it. Yes, you may guess that -- the only possible missing stuff is Boost.Python libraries, so add path to it into PATH environment variable -- for me, it is C:\local\boost_1_64_0\lib64-msvc-14.0.
Then the problem is solved. Note: some answers in other related questions may suggest build as a static library, That way, you will got another import error: DLL load failed: %1 is not a valid Win32 application. So just build as DLL. PS: you don't need to specify boost_python-vc140-mt-1_64.lib or boost_python-vc140-mt-gd-1_64.lib in Property Pages->Linker->Input->Additional Dependencies as some comments suggested.
Post a Comment for "The Dll Created By Boost.python Cannot Be Imported (following Boost Python's Quickstart)"