c++ - Building boost::python module with SCons under Windows -


i'm trying build boost::python module using scons. i've managed find code snippets on web , stitch them builds correctly on linux. have major problems on windows (using visual studio 2013 compiler). here's code:

import distutils.sysconfig, os,sys   def tool_boost_distutils(env):     vars = distutils.sysconfig.get_config_vars('cc', 'cxx', 'opt', 'basecflags', 'ccshared', 'ldshared', 'so') in range(len(vars)):     if vars[i] none:         vars[i] = "" (cc, cxx, opt, basecflags, ccshared, ldshared, so_ext) = vars     env.appendunique(cpppath=[distutils.sysconfig.get_python_inc(), "d:/boost-vs2013/include/boost-1_57"])  if sys.platform == "win32":     print "configuring windows"      env.appendunique(cxxflags=["/md","/ehsc"])       else:     env.appendunique(libs="boost_python")     env.appendunique(cxxflags =["-std=c++11"])  env['shlibsuffix']=so_ext env.appendunique(libpath = [distutils.sysconfig.get_python_inc()+"/libs", distutils.sysconfig.prefix+"/libs","d:/boost-vs2013/lib"])  default('.') env=environment(tools=['default', tool_boost_distutils],target_arch = 'x86') env.sharedlibrary(target='runga', source=['runga.cpp']) 

during build, following files created:

runga.obj

runga.pyd

runga.exp

runga.lib

to import module need .dll file instead of .lib, i'm not sure how properly.

edit 04.06.15: when trying import runga module (by 'import runga'), following error message: 'importerror: dll load failed : specified module not found.'

edit2 04.06.15:

i've managed solve problem. turned out .dll file boost python missing project's directory , system paths , runga.pyd depended on it. thank help.

you generating .dll need, has been renamed .pyd file. needs have leading _ in it's filename before python module load it. can appending following line sconstruct...

if sys.platform == "win32":     print "configuring windows"      env.appendunique(cxxflags=["/md","/ehsc"])     env.replace(ldmoduleprefix='_',                 shlibprefix='_') 

the order of building see runga.obj being built runga.cpp file, library runga.lib gets built, , runga.exp , runga.lib used create runga.pyd. is, exporting .dll you, renaming .pyd.

this different see on linux, end runga.o, runga.py, , _runga.so. on linux dynamic library needs named _module.so, , on windows, needs named _module.pyd.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -