I can't use .def(str(self))
I write a simple example, without `str', I can build it well, but with
this one, I can't build
//Rational.cpp
#include <boost/python.hpp>
#include <iostream>
using namespace std;
using namespace boost::python;
class Rational
{};
ostream& operator<<(ostr eam& os, Rational r){
return os;
}
BOOST_PYTHON_MO DULE(Rational)
{
class_<Rational >("Rational")
..def(str(self) ) // __str__
;
}
// end.
I don't know how to write Jamfile, so I write a Makefile, it works if i
don't use .def(str(self))
# Makefile
CC = g++
CFLAGS = -Wall -W -fPIC -I/usr/include/boost \
-I/usr/include/python2.3 -DBOOST_PYTHON_D YNAMIC_LIB \
-O2
LDFLAGS = -L/usr/local/lib -lboost_python -L/usr/lib/python2.3 \
-Wl,-rpath-link,. -fPIC
CXXFLAGS = $(CFLAGS)
SLIB = hello.so Rational.so
all: $(SLIB)
%.so : %.o
/usr/bin/objcopy --set-section-flags .debug_str=cont ents,debug
$^
$(CC) $(LDFLAGS) $^ -shared -o $@
clean :
rm -f $(WORLD) $(OBJS)
# end.
or a simple setup.py, it also works if I don't use `str'
# setup.py
from distutils.core import setup, Extension
ext_modules = [Extension('Rati onal', ['Rational.cpp'],
define_macros=[('BOOST_PYTHON_ DYNAMIC_LIB',
None)],
libraries=['boost_python'])]
setup(name="itc c",
version="0.2.2" ,
author='Li Daobing',
au************* ********@gmail. com',
ext_modules = ext_modules
)
# end.
This is the error message:
$ make
g++ -Wall -W -fPIC -I/usr/include/boost -I/usr/include/python2.3
-DBOOST_PYTHON_D YNAMIC_LIB -O2 -c -o Rational.o Rational.cpp
Rational.cpp: In function `std::ostream& operator<<(std: :ostream&,
Rational)':
Rational.cpp:10 : warning: unused parameter `Rational r'
/usr/include/boost/python/def_visitor.hpp : In static member function
`static
void boost::python:: def_visitor_acc ess::visit(cons t V&, classT&)
[with V =
boost::python:: def_visitor<boo st::python::api ::object>, classT =
boost::python:: class_<Rational ,
boost::python:: detail::not_spe cified,
boost::python:: detail::not_spe cified,
boost::python:: detail::not_spe cified>]
':
/usr/include/boost/python/def_visitor.hpp :67: instantiated from `void
boost::python:: def_visitor<Der ivedVisitor>::v isit(classT&) const [with
classT = boost::python:: class_<Rational ,
boost::python:: detail::not_spe cified,
boost::python:: detail::not_spe cified,
boost::python:: detail::not_spe cified>, DerivedVisitor =
boost::python:: api::object]'
/usr/include/boost/python/class.hpp:225: instantiated from
`boost::python: :class_<T, X1, X2, X3>& boost::python:: class_<T, X1, X2,
X3>::def(const boost::python:: def_visitor<Der ived>&) [with Derived =
boost::python:: api::object, W = Rational, X1 =
boost::python:: detail::not_spe cified, X2 =
boost::python:: detail::not_spe cified, X3 =
boost::python:: detail::not_spe cified]'
Rational.cpp:15 : instantiated from here
/usr/include/boost/python/def_visitor.hpp :31: error: no matching
function for
call to
`boost::python: :api::object::v isit(boost::pyt hon::class_<Rat ional,
boost::python:: detail::not_spe cified,
boost::python:: detail::not_spe cified,
boost::python:: detail::not_spe cified>&) const'
make: *** [Rational.o] Error 1 0 2125 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Link |
last post by:
Dear sir,
I am used to developing C program on MSVC7.0 platform.
This is my first time to use Python for calling by C program.
Now, it is hard to deal with the problem about extracting the variable
which be definied in Python. That how can I do?
I have gotten the JPython 's sample that the following code can be looked.
Have anyone help me to obtain same results that be called by Python's C API?
What do I mean?
|
by: Andrew Ayre |
last post by:
Hi, I can't seem to get the library built, and any help is greatly
appreciated. Here is the info:
Windows XP
Borland C++ Builder 5
Latest Boost source code (downloaded at the weekend)
Windows binary bjam 3.1.11
Command line:
|
by: Max Wilson |
last post by:
Hi,
Has anyone here built Boost.Python modules under MinGW? I'm trying to
build the Boost.Python tutorial under MinGW and getting an error that
says it depends on MSVC, which puzzles me because Boost built using
g++. Here's some of my output:
Student@YGGDRASIL /c/Boost/libs/python/example/tutorial
$ bjam -sTOOLS=mingw -d+2
....found 1508 targets...
|
by: Osiris |
last post by:
I have these pieces of C-code (NOT C++ !!) I want to call from Python.
I found Boost.
I have MS Visual Studio 2005 with C++.
is this the idea:
I write the following C source file:
============================
#include <iostream>
#include <stdafx.h>
|
by: Shawn McGrath |
last post by:
Hi, I'm trying to expose a C++ class' internals to python via
boost::python. I can do integer/boolean functions fine, but as soon
as I do a string get/set it craps out.
boost::python::class_<Entity, std::auto_ptr<pyEntity("Entity")
//publics
.def("isActive", &Entity::isActive) //bool
.def("activate", &Entity::activate) //bool
.def("deactivate", &Entity::deactivate) //bool
//...
| |
by: mr_gees100_peas |
last post by:
Hi,
I've been trying for days to make either boost.python or swig to
work for me. The one I have gotten the closest to is boost. Note that
this is for windows XP. I'm not much of an unix person besides doing
simple ls and copy paste.
What I have done is to download the boost library: C:\boost_1_34_0
I downloaded the bjam library: C:\boost-jam-3.1.14-1-ntx86
|
by: devito |
last post by:
hi there,
for some days i try to build the boost.python tutorial "hello world"
without bjam on winxp by using mingw.
so i wrote a *.bat-file like the following:
// --- snip
--------------------------------------------------------------------------------------
@echo off
SETLOCAL
|
by: Till Kranz |
last post by:
Hi,
I tried to get started with Boost.Python. unfortunately I never used the
bjam build system before. As it is explained in the documentation I tried
to adapt the the files form the examples directory. I copied 'Jamroot',
'boost_build.jam' and 'extending.cpp' to '~/test/'. But I am lost as to
what to do now. The docu says I should adjust the 'use-project' path. But
what to? I am using a Gentoo system, so there is no boost directory. The...
|
by: Stodge |
last post by:
Hi folks, new to Boost Python and struggling to build a prototype at
work. I thought I'd start with a conceptual question to help clarify
my understanding. I already have a basic prototype working nicely but
I'm having a few issues, which I may post about later.
A brief functional rundown of what I'm trying to prototype. Hopefully
my explanation doesn't get too confusing!
I'm embedding a python module into an application; Python will...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |