build boost 1.46 and python3.2

There is one build error when building boost 1.46 + python 3.2 via VC++ 2008:

libs/python/src/converter/builtin_converters.cpp(436) : error C2664: 'PyUnicodeUCS2_AsWideChar' : cannot convert parameter 1 from 'PyUnicodeObject *' to 'PyObject *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

 

Solution: change libs/python/src/converter/builtin_converters.cpp(436)

 

 

      static std::wstring extract(PyObject* intermediate)
      {
          std::wstring result(::PyObject_Length(intermediate), L' ');
          if (!result.empty())
          {
              int err = PyUnicode_AsWideChar(
                  /*(PyUnicodeObject *)*/intermediate     // change this line, comment out the C style cast!!!
                , &result[0]
                , result.size());

              if (err == -1)
                  throw_error_already_set();
          }
          return result;
      }

 

Note: I also append the following to D:/opensource/boost_1_46_0/tools/build/v2/user-config.jam

###########################################################
using python
    : 3.2                         # Version
    : C://Python32//python.exe    # Python Path
    : C://Python32//Include        # include path(s) -they may be not really needed here
    : C://Python32//libs        # lib path(s) - they may be not really needed here
    : <python-debugging>off <define>BOOST_ALL_NO_LIB=1
    ; 
using python
    : 3.2                         # Version
    : C://Python32//python.exe    # Python Path
    : C://Python32//Include        # include path(s) -they may be not really needed here
    : C://Python32//libs        # lib path(s) - they may be not really needed here
    : <python-debugging>on <define>BOOST_ALL_NO_LIB=1
    ; 
###########################################################

 

I also need to modify the following line in D:/src/boost_1_46_0/libs/python/src/module.cpp

BOOST_PYTHON_DECL PyObject* init_module(PyModuleDef& moduledef, void(*init_function)())

Otherwise there is a link error: 

error LNK2001: unresolved external symbol "__declspec(dllimport) struct _object * __cdecl boost::python::detail::init_module(struct PyModuleDef &,void (__cdecl*)(void))" (__imp_?init_module@detail@python@boost@@YAPAU_object@@AAUPyModuleDef@@P6AXXZ@Z)

 

boost.log is only compatible with boost.filesystem v2, but boost 1.46 is using boost.filesystem v3 by default.

 

compile-c-c++ bin.v2/libs/log/build/msvc-10.0/release/link-static/runtime-link-static/threading-multi/text_file_backend.obj

text_file_backend.cpp

./boost/log/detail/universal_path.hpp(46) : error C2039: 'external_string_type' : is not a member of 'boost::filesystem3::path'

 

The following command can be used to build boost.log.

bjam.exe --with-log --toolset=msvc stage --build-type=complete define=BOOST_FILESYSTEM_VERSION=2

 

I created a batch file to build the boost library.

 

rem call "%VS100COMNTOOLS%/../../vc/bin/vcvars32.bat"

call "%VS90COMNTOOLS%/../../VC/vcvarsall.bat"

cd /d D:/opensource/boost_1_46_0

echo Update D:/opensource/boost_1_46_0/tools/build/v2/user-config.jam

call bootstrap.bat

set ICU_PATH=D:/opensource/icu4c-4_6-src/icu

echo "build start" >> buildtime.txt

time /t  >> buildtime.txt

bjam.exe --toolset=msvc stage --build-type=complete -sBZIP2_SOURCE=D:/opensource/bzip2-1.0.5 -sZLIB_SOURCE=D:/opensource/zlib-1.2.5 -sICU_PATH="D:/opensource/icu4c-4_4_1-Win32-msvc9/icu" >> msvc10.log

time /t  >> buildtime.txt

echo "build finished" >> buildtime.txt

 

Use boost.log in DLL

When I am using boost.log in DLL, the Debug configuration will raise the following error:

 

---------------------------

Microsoft Visual C++ Debug Library

---------------------------

Debug Assertion Failed!

 

Program: E:/svn/trunk/Debug/Onegad.exe

File: f:/dd/vctools/vc7libs/ship/atlmfc/src/mfc/dllinit.cpp

Line: 587

 

For information on how your program can cause an assertion

failure, see the Visual C++ documentation on asserts.

 

(Press Retry to debug the application)

---------------------------

Abort   Retry   Ignore   

---------------------------

The problem is fixed by adding BOOST_THREAD_DYN_LINK preprocessor to my DLL project. 

 

 

 

compile with Intel C++ compiler

 

C:/tmp/boost_1_35_0/libs/program_options/build>../../../bjam.exe --toolset=intel release

C:/tmp/boost_1_35_0/libs/program_options/build>../../../bjam.exe --toolset=intel 

C:/tmp/boost_1_35_0/libs/program_options/build>../../../bjam.exe --toolset=intel link=static debug release 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值