Re: [C++-sig] Linking issues with Boost.Python 1.69.0, Python 2.7, MSVC 14.0

2019-03-27 Thread Stefan Ring
On Tue, Mar 26, 2019 at 3:27 PM Sarah Rust  wrote:
>
> Hello!
>
> I have been trying to build and link the latest Boost.Python to work with 
> Python 2.7 and my Visual Studio 2015 project (MSVC 14.0) with x64 
> configuration. I've added the Boost library and Boost include directory to my 
> project's properties, but I am getting the following error when I create a 
> BOOST_PYTHON_MODULE:
>
> error LNK2001: unresolved external symbol "__declspec(dllimport) struct 
> _object * __cdecl boost::python::detail::init_module(char const *,void 
> (__cdecl*)(void))" 
> (__imp_?init_module@detail@python@boost@@YAPEAU_object@@PEBDP6AXXZ@Z)

Have you built Python yourself? With which compiler? Are you linking
against its import lib (for DLL use at run time)? Could you maybe use
the static version of Boost?

Actually while writing this, a though came up: Are you even linking
against the Boost Python library?

> Please let me know how others are doing this.

Probably not at all ;).
___
Cplusplus-sig mailing list
[email protected]
https://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] argument conversion of numpy.int64 to double

2019-03-27 Thread Pavol Juhas
Hello,

After wrapping a simple C++ function of a double argument with
boost python, I have noticed it crashes when called from Python
with a numpy.int64 value.  This is a likely situation, for example when
evaluated for values from numpy.arange.
Please see below for a minimum example.

Is there some simple way of telling the wrapper how to handle
numpy.int64 arguments?

BTW, I have noticed that the boost/numpy library sets up several scalar
converters on its initialization - this happens in boost/python/numpy.hpp

 and
then in the register_scalar_converters

function.
However, adding a
call to boost::python::numpy::initialize did not make a difference
in my example.

Thank you for any advice.  Best,

Pavol

// dbfunction.cpp


#include 
#include 
#include 

double duplicate(double x)
{
return 2 * x;
}

BOOST_PYTHON_MODULE(dbfunction)
{
using boost::python::def;
// no difference with line below
// boost::python::numpy::initialize();
def("duplicate", duplicate);
}

//
---

# TEST

$ python -c 'import dbfunction, numpy;
dbfunction.duplicate(numpy.int64(0))'
Traceback (most recent call last):
  File "", line 1, in 
Boost.Python.ArgumentError: Python argument types in
dbfunction.duplicate(numpy.int64)
did not match C++ signature:
duplicate(double)
___
Cplusplus-sig mailing list
[email protected]
https://mail.python.org/mailman/listinfo/cplusplus-sig