[Tutor] C API Tutorial Class Question

Arthur Coleman arthur at nowsol.com
Thu May 3 21:48:12 CEST 2007

I am using Windows XP and have successfully build the Boost libraries, plus
boost_python.dll.  I am trying to work through the C API tutorial where the
file hello.cpp is found at libs/python/example/tutorial.  I have been able
to compile and execute the first example building the supplied hello.cpp
file that allows Python to import a C function, but when I move onto the
next example in the tutorial:


struct World
    void set(std::string msg) { this->msg = msg; }
    std::string greet() { return msg; }
    std::string msg;


#include <boost/python.hpp>
using namespace boost::python;
        .def("greet", &World::greet)
        .def("set", &World::set)


 I replace the original contents of hello.cpp with the above code and using
bjam tried to build hello.pyd.  I receive the following errors:


...found 1513 targets...

...updating 4 targets...

vc-C++ bin\tutorial\hello.pyd\vc-8_0\debug\threading-multi\hello.obj


hello.cpp(22) : error C2976: 'boost::python::class_' : too few template

        G:\boost_1_33_1\boost/python/def_visitor.hpp(14) : see declaration
of 'boost::python::class_'

hello.cpp(22) : error C2440: '<function-style-cast>' : cannot convert from
'const char [6]' to 'boost::python::class_'

        Source or target has incomplete type

hello.cpp(22) : error C2228: left of '.def' must have class/struct/union

hello.cpp(22) : error C2228: left of '.def' must have class/struct/union

hello.cpp(22) : error C2143: syntax error : missing ';' before '}'


    CALL "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.BAT"

    "C:\Program Files\Microsoft Visual Studio 8\VC\bin\cl" /Zm800 -nologo
/Zc:forScope /Zc:wchar_t -I"bin\tutorial"  -I"G:\boost_1_33_1"


...failed vc-C++

...skipped <@tutorial\hello.pyd\vc-8_0\debug\threading-multi>hello.CMD for
lack of <@tutorial\hello.pyd\vc-8_0\debug\threading-multi>hello.obj...

...skipped <@tutorial\hello.pyd\vc-8_0\debug\threading-multi>hello.pyd for
lack of <@tutorial\hello.pyd\vc-8_0\debug\threading-multi>hello.CMD...

...skipped <@tutorial\hello.pyd\vc-8_0\debug\threading-multi>hello.lib for
lack of <@tutorial\hello.pyd\vc-8_0\debug\threading-multi>hello.CMD...

...failed updating 1 target...

...skipped 3 targets...


I reviewed the definition of class_ in file def_visitor.hpp and found that
it was defined as:


template<T1, X1, X2, X3> class class_;


I have tried searching the FAQ and the Web and so far no luck.  I would
appreciate any help.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070503/aaaeb344/attachment-0001.html 

More information about the Tutor mailing list