pygccxml-development Mailing List for C++ Python language bindings (Page 19)
Brought to you by:
mbaas,
roman_yakovenko
You can subscribe to this list here.
2006 |
Jan
|
Feb
(6) |
Mar
(160) |
Apr
(96) |
May
(152) |
Jun
(72) |
Jul
(99) |
Aug
(189) |
Sep
(161) |
Oct
(110) |
Nov
(9) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(13) |
Feb
(48) |
Mar
(35) |
Apr
(7) |
May
(37) |
Jun
(8) |
Jul
(15) |
Aug
(8) |
Sep
(2) |
Oct
(1) |
Nov
(2) |
Dec
(38) |
2008 |
Jan
(11) |
Feb
(29) |
Mar
(17) |
Apr
(3) |
May
|
Jun
(64) |
Jul
(49) |
Aug
(51) |
Sep
(18) |
Oct
(22) |
Nov
(9) |
Dec
(9) |
2009 |
Jan
(28) |
Feb
(15) |
Mar
(2) |
Apr
(11) |
May
(6) |
Jun
(2) |
Jul
(3) |
Aug
(34) |
Sep
(5) |
Oct
(7) |
Nov
(13) |
Dec
(14) |
2010 |
Jan
(39) |
Feb
(3) |
Mar
(3) |
Apr
(14) |
May
(11) |
Jun
(8) |
Jul
(9) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
(3) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2016 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2021 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
From: Roman Y. <rom...@gm...> - 2008-06-10 07:01:32
|
On Mon, Jun 9, 2008 at 1:36 PM, Gustavo Carneiro <gjc...@gm...> wrote: > As seen in > > https://bugs.launchpad.net/bugs/238455 > > I am getting problems in PyBindGen related to differences in types like > "char*" vs "char *", also the position of the 'const' keyword may change, > etc. > > I am looking for some robust, pure python code to parse C types and extract > features from it, or produce a canonical type string, so that I can use it > PyBindGen. Does something like this exist in pygccxml No, but we can discuss such addition to pygccxml. I think this is a nice & useful feature. > or elsewhere that I can steal? :-) May be from here: http://code.google.com/p/cppclean/wiki/InternalDesign -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2008-06-10 05:56:57
|
On Tue, Jun 10, 2008 at 1:42 AM, Vincent Ferries <vin...@gm...> wrote: > > > 2008/6/9 Roman Yakovenko <rom...@gm...>: >> >> On Mon, Jun 9, 2008 at 6:35 PM, Vincent Ferries >> <vin...@gm...> wrote: >> > I now include my cpp code with the directive : >> > mb.code_creator.add_include(myCorrespondingCppFile.cpp) >> > >> > Is this the right way to do it? >> >> No. I generally doesn't include cpp files. >> >> I think the problem is here(scons file): >> >> def get_py_ferespost_files(): >> source_files = filter(lambda s: s.endswith('.cpp'), >> os.listdir(settings.generated_files_dir)) >> return map(lambda fname: os.path.join(settings.generated_files_dir, >> fname), source_files) > > I currently use this method to generate the library from the generated > source. > >> >> If you generate code to a directory other than wrapped library code, >> than the cpp files of the library ( forepost )is not included into the >> build. Just update your scons. > > That's the case, but there are many folders (and subfolders) where the > sources are. > I don't know where I need to generate and how I can manage all the > dependencies. This question is not related to Py++. I suggest you to read SCONS documentation. >> >> > And another question (yes, again...). >> > The project I'm trying to wrap is quite complex and has a lot of >> > cross-dependencies. >> > (a file A including another file B which include A for example). >> > I don't know how to déclare such dependencies using py++. >> > Any help would be appreciated. >> >> What do you mean "to declare dependencies"? > > If I understand what you were saying, I can declare all the .h files into > one same .h file and compile it to make the full library. > > Then, I have to compile all the .cpp sources and generated .cpp together to > compile my .so file? No. You'd better compiler the project to standalone library and than add it to the link line. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-09 22:42:17
|
2008/6/9 Roman Yakovenko <rom...@gm...>: > On Mon, Jun 9, 2008 at 6:35 PM, Vincent Ferries > <vin...@gm...> wrote: > > I now include my cpp code with the directive : > > mb.code_creator.add_include(myCorrespondingCppFile.cpp) > > > > Is this the right way to do it? > > No. I generally doesn't include cpp files. > > I think the problem is here(scons file): > > def get_py_ferespost_files(): > source_files = filter(lambda s: s.endswith('.cpp'), > os.listdir(settings.generated_files_dir)) > return map(lambda fname: os.path.join(settings.generated_files_dir, > fname), source_files) > I currently use this method to generate the library from the generated source. > > If you generate code to a directory other than wrapped library code, > than the cpp files of the library ( forepost )is not included into the > build. Just update your scons. > That's the case, but there are many folders (and subfolders) where the sources are. I don't know where I need to generate and how I can manage all the dependencies. > > > > And another question (yes, again...). > > The project I'm trying to wrap is quite complex and has a lot of > > cross-dependencies. > > (a file A including another file B which include A for example). > > I don't know how to déclare such dependencies using py++. > > Any help would be appreciated. > > What do you mean "to declare dependencies"? > If I understand what you were saying, I can declare all the .h files into one same .h file and compile it to make the full library. Then, I have to compile all the .cpp sources and generated .cpp together to compile my .so file? > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Roman Y. <rom...@gm...> - 2008-06-09 19:29:43
|
On Mon, Jun 9, 2008 at 6:35 PM, Vincent Ferries <vin...@gm...> wrote: > I now include my cpp code with the directive : > mb.code_creator.add_include(myCorrespondingCppFile.cpp) > > Is this the right way to do it? No. I generally doesn't include cpp files. I think the problem is here(scons file): def get_py_ferespost_files(): source_files = filter(lambda s: s.endswith('.cpp'), os.listdir(settings.generated_files_dir)) return map(lambda fname: os.path.join(settings.generated_files_dir, fname), source_files) If you generate code to a directory other than wrapped library code, than the cpp files of the library ( forepost )is not included into the build. Just update your scons. > And another question (yes, again...). > The project I'm trying to wrap is quite complex and has a lot of > cross-dependencies. > (a file A including another file B which include A for example). > I don't know how to déclare such dependencies using py++. > Any help would be appreciated. What do you mean "to declare dependencies"? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-09 15:35:40
|
I now include my cpp code with the directive : mb.code_creator.add_include(myCorrespondingCppFile.cpp) Is this the right way to do it? And another question (yes, again...). The project I'm trying to wrap is quite complex and has a lot of cross-dependencies. (a file A including another file B which include A for example). I don't know how to déclare such dependencies using py++. Any help would be appreciated. 2008/6/9, Vincent Ferries <vin...@gm...>: > I tested my examples again. > > I've merged a .h and the corresponding .cpp files together and it seems to > work. > > According to me, the code in the .cpp file was not read, that's the > reason why the method body code was never found. > > What was I doing wrong? > What did I miss to include the .cpp code? > > Thanks in advance. > > 2008/6/6, Vincent Ferries <vin...@gm...>: >> Unfortunately, ferespost is just a C++ library of nastran files post >> treatment. >> It has been written et wrapped in order to be implemented in ruby. >> >> It's open source and I work with the pure C++ sources, trying to wrap them >> using py++. >> This lib actually works included in a python app. >> I don't think the ferespost conceptor has the ability to help me >> converting >> it to python. >> >> I'll try to verify/adjust the LD_LIBRARY_PATH tomorrow in the morning at >> work... >> But I didn't have to do that with the pyeasybmp example... >> > |
From: Gustavo C. <gjc...@gm...> - 2008-06-09 10:36:28
|
As seen in https://bugs.launchpad.net/bugs/238455 I am getting problems in PyBindGen related to differences in types like "char*" vs "char *", also the position of the 'const' keyword may change, etc. I am looking for some robust, pure python code to parse C types and extract features from it, or produce a canonical type string, so that I can use it PyBindGen. Does something like this exist in pygccxml or elsewhere that I can steal? :-) -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert |
From: Vincent F. <vin...@gm...> - 2008-06-09 07:47:26
|
I tested my examples again. I've merged a .h and the corresponding .cpp files together and it seems to work. According to me, the code in the .cpp file was not read, that's the reason why the method body code was never found. What was I doing wrong? What did I miss to include the .cpp code? Thanks in advance. 2008/6/6, Vincent Ferries <vin...@gm...>: > Unfortunately, ferespost is just a C++ library of nastran files post > treatment. > It has been written et wrapped in order to be implemented in ruby. > > It's open source and I work with the pure C++ sources, trying to wrap them > using py++. > This lib actually works included in a python app. > I don't think the ferespost conceptor has the ability to help me converting > it to python. > > I'll try to verify/adjust the LD_LIBRARY_PATH tomorrow in the morning at > work... > But I didn't have to do that with the pyeasybmp example... > |
From: Vincent F. <vin...@gm...> - 2008-06-05 22:22:51
|
Unfortunately, ferespost is just a C++ library of nastran files post treatment. It has been written et wrapped in order to be implemented in ruby. It's open source and I work with the pure C++ sources, trying to wrap them using py++. This lib actually works included in a python app. I don't think the ferespost conceptor has the ability to help me converting it to python. I'll try to verify/adjust the LD_LIBRARY_PATH tomorrow in the morning at work... But I didn't have to do that with the pyeasybmp example... |
From: Roman Y. <rom...@gm...> - 2008-06-05 18:43:53
|
On Thu, Jun 5, 2008 at 6:07 PM, Vincent Ferries <vin...@gm...> wrote: > I successfully runned the example pyeasybmp on my platform. > I can run the examples from start to end without any problem. > I generate my .so libs with the same environment variables, and the > same scontruct file. > > I tried to make a lib of a very simple file with no dependency. > I still encounter the same problem... > > The only difference I see is that there are just .h files in the > pyeasybmp example and that I have a .h and a .cpp file. > Does it influence the results? > How can I do it then? > > Here is the err.h I'm trying to wrap, the error message is still the > same (it follows) > > > > > // > // Copyright 2005-2008 Renaud Sizaire > // > // This file is part of FeResPost. > // > // FeResPost is free software; you can redistribute it and/or modify > // it under the terms of the GNU General Public License as published by > // the Free Software Foundation; either version 2 of the License, or > // (at your option) any later version. > // > // FeResPost is distributed in the hope that it will be useful, > // but WITHOUT ANY WARRANTY; without even the implied warranty of > // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > // GNU General Public License for more details. > // > // You should have received a copy of the GNU General Public License > // along with FeResPost; if not, write to the Free Software > // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > // > > #ifndef ERR_H > #define ERR_H > > #include <iostream> > #include <stdexcept> > #include <string> > > namespace postLib { > > class err { > > private : > > std::string functionName ; > std::string fileName ; > int lineNumber ; > std::string message ; > > static bool Ok ; > > public : > > err(void) ; > err(std::string fuName,std::string fiName,int liNumber,std::string msg) ; > err(std::string fiName,int liNumber,std::string msg) ; > err(const err &in) ; > ~err(void) ; > > void write(std::ostream &out) const ; > void exec(std::ostream &out) ; > void exec(void) ; > > static void setOk(bool) ; > static bool getOk(void) ; > > static void flushStdStreams(void) ; > > } ; > > } > > #define errThrow(a,b) { \ > err::flushStdStreams(); \ > err brol(a,__FILE__,__LINE__,b); \ > brol.write(std::cerr); \ > throw(brol); \ > } > > #define errWrite(a,b) { \ > err::flushStdStreams(); \ > err (a,__FILE__,__LINE__,b).exec(); \ > err::setOk(false); \ > } > > #define catchAll(a,b) catch(err) { \ > err::flushStdStreams(); \ > std::cerr << "Error caught in : " << __FILE__ << ":" << __LINE__ << endl ; \ > std::cerr << " in function : " << a << endl ; \ > std::cerr << " with message : " << b << endl ; \ > err brol(a,__FILE__,__LINE__,b) ; \ > throw(brol) ; \ > } \ > catch(std::out_of_range) { \ > err::flushStdStreams(); \ > std::cerr << "Error caught in : " << __FILE__ << ":" << __LINE__ << endl ; \ > std::cerr << " in function : " << a << endl ; \ > std::cerr << " with message : " << b << endl ; \ > std::cerr << " error type : std::out_of_range" << endl ; \ > err brol(a,__FILE__,__LINE__,b) ; \ > throw(brol) ; \ > } \ > catch(std::bad_alloc) { \ > err::flushStdStreams(); \ > std::cerr << "Error caught in : " << __FILE__ << ":" << __LINE__ << endl ; \ > std::cerr << " in function : " << a << endl ; \ > std::cerr << " with message : " << b << endl ; \ > std::cerr << " error type : std::bad_alloc" << endl ; \ > err brol(a,__FILE__,__LINE__,b) ; \ > throw(brol) ; \ > } \ > catch(...) { \ > err::flushStdStreams(); \ > std::cerr << "Error caught in : " << __FILE__ << ":" << __LINE__ << endl ; \ > std::cerr << " in function : " << a << endl ; \ > std::cerr << " with message : " << b << endl ; \ > std::cerr << " error type : unknown" << endl ; \ > err brol(a,__FILE__,__LINE__,b) ; \ > throw(brol) ; \ > } > > #endif > > > > > Traceback (most recent call last): > File "test.py", line 4, in ? > import ferespost > ImportError: /people/ferries/ferespost/unittests/ferespost.so: > undefined symbol: _ZN7postLib7errC1ERKS0_ > > > Thanks again... I think the error is not related to Boost.Python. Did you tried to create small executable that uses the library you wrap? I guess you will get same error. May it worse to take this error to ferespost developers? Did you try to adjust LD_LIBRARY_PATH, so it will contain path to ferespost so file? If ferespost supports static linakge, maybe it worse to try that mode? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-05 15:52:10
|
Ok Mea Culpa, RTFM as they say... I just found that : Version 0.7.1 Attention - this going to be last version that is tested with Python 2.3 New fundamental types has been added complex float complex double complex long double I'll upgrade it soon and test again. 2008/6/5, Vincent Ferries <vin...@gm...>: > gccxml seems not to be able to parse the file "complex" which is a > standart C++ library. > I've googled a long long time, found some people which had a similar > problem with no answer. > > I'm using gcc 4.1.2, on a Debian system, with gcc-xml 0.7.0. > > I have the following error : > > (the file result.h just import it at line 25 : #include <complex>) > > > > > > INFO Parsing source file > "/people/ferries/ferespost/SRC/COMMON/algebra/matrix3.h" ... > > INFO gccxml cmd: /usr/bin/gccxml -I"/people/ferries/ferespost/SRC" > -I"/people/ferries/ferespost/SRC" > "/people/ferries/ferespost/SRC/COMMON/algebra/matrix3.h" > -fxml="/tmp/tmp3uS2qo.xml" > Traceback (most recent call last): > File "generate_code.py", line 63, in ? > export() > File "generate_code.py", line 43, in export > mb = module_builder.module_builder_t(header_files, > gccxml_path=settings.gccxml_path, > working_directory=settings.ferespost_path, > include_paths=[settings.ferespost_path], define_symbols=[]) > File > "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", > line 90, in __init__ > , indexing_suite_version) > File > "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", > line 144, in __parse_declarations > decls = reader.read_files( files, compilation_mode ) > File "/usr/lib/python2.4/site-packages/pygccxml/parser/project_reader.py", > line 225, in read_files > return self.__parse_file_by_file(files) > File "/usr/lib/python2.4/site-packages/pygccxml/parser/project_reader.py", > line 250, in __parse_file_by_file > decls = reader.read_file( header ) > File "/usr/lib/python2.4/site-packages/pygccxml/parser/source_reader.py", > line 198, in read_file > return self.read_gccxml_file( source_file ) > File "/usr/lib/python2.4/site-packages/pygccxml/parser/source_reader.py", > line 225, in read_gccxml_file > raise error > pygccxml.parser.source_reader.gccxml_runtime_error_t: Error occured > while running GCC-XML: In file included from > /people/ferries/ferespost/SRC/COMMON/result/result.h:25, > from > /people/ferries/ferespost/SRC/COMMON/algebra/matrix3.h:28: > /usr/include/c++/4.1.2/complex: In function `__complex__ float > std::__complex_log(__complex__ float)': > /usr/include/c++/4.1.2/complex:754: error: `__builtin_clogf' undeclared > (first > use this function) > /usr/include/c++/4.1.2/complex:754: error: (Each undeclared identifier is > reported only once for each function it appears in.) > /usr/include/c++/4.1.2/complex: In function `__complex__ double > std::__complex_log(__complex__ double)': > /usr/include/c++/4.1.2/complex:757: error: `__builtin_clog' undeclared > (first > use this function) > /usr/include/c++/4.1.2/complex: In function `__complex__ long double > std::__complex_log(__complex__ long double&)': > /usr/include/c++/4.1.2/complex:761: error: `__builtin_clogl' undeclared > (first > use this function) > > > Any workaround? > |
From: Vincent F. <vin...@gm...> - 2008-06-05 15:07:19
|
I successfully runned the example pyeasybmp on my platform. I can run the examples from start to end without any problem. I generate my .so libs with the same environment variables, and the same scontruct file. I tried to make a lib of a very simple file with no dependency. I still encounter the same problem... The only difference I see is that there are just .h files in the pyeasybmp example and that I have a .h and a .cpp file. Does it influence the results? How can I do it then? Here is the err.h I'm trying to wrap, the error message is still the same (it follows) // // Copyright 2005-2008 Renaud Sizaire // // This file is part of FeResPost. // // FeResPost is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // FeResPost is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with FeResPost; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #ifndef ERR_H #define ERR_H #include <iostream> #include <stdexcept> #include <string> namespace postLib { class err { private : std::string functionName ; std::string fileName ; int lineNumber ; std::string message ; static bool Ok ; public : err(void) ; err(std::string fuName,std::string fiName,int liNumber,std::string msg) ; err(std::string fiName,int liNumber,std::string msg) ; err(const err &in) ; ~err(void) ; void write(std::ostream &out) const ; void exec(std::ostream &out) ; void exec(void) ; static void setOk(bool) ; static bool getOk(void) ; static void flushStdStreams(void) ; } ; } #define errThrow(a,b) { \ err::flushStdStreams(); \ err brol(a,__FILE__,__LINE__,b); \ brol.write(std::cerr); \ throw(brol); \ } #define errWrite(a,b) { \ err::flushStdStreams(); \ err (a,__FILE__,__LINE__,b).exec(); \ err::setOk(false); \ } #define catchAll(a,b) catch(err) { \ err::flushStdStreams(); \ std::cerr << "Error caught in : " << __FILE__ << ":" << __LINE__ << endl ; \ std::cerr << " in function : " << a << endl ; \ std::cerr << " with message : " << b << endl ; \ err brol(a,__FILE__,__LINE__,b) ; \ throw(brol) ; \ } \ catch(std::out_of_range) { \ err::flushStdStreams(); \ std::cerr << "Error caught in : " << __FILE__ << ":" << __LINE__ << endl ; \ std::cerr << " in function : " << a << endl ; \ std::cerr << " with message : " << b << endl ; \ std::cerr << " error type : std::out_of_range" << endl ; \ err brol(a,__FILE__,__LINE__,b) ; \ throw(brol) ; \ } \ catch(std::bad_alloc) { \ err::flushStdStreams(); \ std::cerr << "Error caught in : " << __FILE__ << ":" << __LINE__ << endl ; \ std::cerr << " in function : " << a << endl ; \ std::cerr << " with message : " << b << endl ; \ std::cerr << " error type : std::bad_alloc" << endl ; \ err brol(a,__FILE__,__LINE__,b) ; \ throw(brol) ; \ } \ catch(...) { \ err::flushStdStreams(); \ std::cerr << "Error caught in : " << __FILE__ << ":" << __LINE__ << endl ; \ std::cerr << " in function : " << a << endl ; \ std::cerr << " with message : " << b << endl ; \ std::cerr << " error type : unknown" << endl ; \ err brol(a,__FILE__,__LINE__,b) ; \ throw(brol) ; \ } #endif Traceback (most recent call last): File "test.py", line 4, in ? import ferespost ImportError: /people/ferries/ferespost/unittests/ferespost.so: undefined symbol: _ZN7postLib7errC1ERKS0_ Thanks again... 2008/6/5, Vincent Ferries <vin...@gm...>: > The most curious thing is that the error deals with the only class I'm > actually trying to make accessible... > I'd have understood if it came from an inclusion class... > > 2008/6/5, Vincent Ferries <vin...@gm...>: >> The library I try to wrap is an open source library called ferespost >> used in aerospace calculation. >> >> I'm currently trying to wrap one of the main classes >> postLib::nastran::dataBase which implements >> postLib::generic::dataBase. >> I generated the wrapping class, addind all the missing include .h and >> defining all the missing call_policies so that I haven't any error >> generating the .cpp file. >> >> I compiled it using the sconstruct file I found in the pyEasyBmp >> example, modifying it according to my configuration. >> >> I also tried to comment all the virtual function definitions to see if >> it was causing my problem. >> >> Do I really have to wrap all of the files/classes from the library I'd >> like to use to be able to compile, or can I simply use a part of it >> like I'm trying to do actually? >> >> 2008/6/4, Roman Yakovenko <rom...@gm...>: >>> On Wed, Jun 4, 2008 at 6:51 PM, Vincent Ferries >>> <vin...@gm...> wrote: >>>> I tried to comment all the virutal method definitions in my generated >>>> .cpp >>>> file. >>>> If I understand what was said on your link, the linker makes dynamic >>>> links for virtual functions which are not redefined in the same file >>>> while compiling which causes errors on runtime if it doesn't find >>>> them, just like in my case. >>>> >>>> But without any virtual function left, it should work. >>>> >>>> I compiled again and still have the same error when importing the >>>> module... >>> >>> If I should guess, than >>> or you forgot to add to the link line some of your libraries >>> or your new module depends on some other so and cannot find it >>> or there is something else :-) >>> >>> -- >>> Roman Yakovenko >>> C++ Python language binding >>> http://www.language-binding.net/ >>> >> > |
From: Vincent F. <vin...@gm...> - 2008-06-05 14:51:11
|
gccxml seems not to be able to parse the file "complex" which is a standart C++ library. I've googled a long long time, found some people which had a similar problem with no answer. I'm using gcc 4.1.2, on a Debian system, with gcc-xml 0.7.0. I have the following error : (the file result.h just import it at line 25 : #include <complex>) INFO Parsing source file "/people/ferries/ferespost/SRC/COMMON/algebra/matrix3.h" ... INFO gccxml cmd: /usr/bin/gccxml -I"/people/ferries/ferespost/SRC" -I"/people/ferries/ferespost/SRC" "/people/ferries/ferespost/SRC/COMMON/algebra/matrix3.h" -fxml="/tmp/tmp3uS2qo.xml" Traceback (most recent call last): File "generate_code.py", line 63, in ? export() File "generate_code.py", line 43, in export mb = module_builder.module_builder_t(header_files, gccxml_path=settings.gccxml_path, working_directory=settings.ferespost_path, include_paths=[settings.ferespost_path], define_symbols=[]) File "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", line 90, in __init__ , indexing_suite_version) File "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", line 144, in __parse_declarations decls = reader.read_files( files, compilation_mode ) File "/usr/lib/python2.4/site-packages/pygccxml/parser/project_reader.py", line 225, in read_files return self.__parse_file_by_file(files) File "/usr/lib/python2.4/site-packages/pygccxml/parser/project_reader.py", line 250, in __parse_file_by_file decls = reader.read_file( header ) File "/usr/lib/python2.4/site-packages/pygccxml/parser/source_reader.py", line 198, in read_file return self.read_gccxml_file( source_file ) File "/usr/lib/python2.4/site-packages/pygccxml/parser/source_reader.py", line 225, in read_gccxml_file raise error pygccxml.parser.source_reader.gccxml_runtime_error_t: Error occured while running GCC-XML: In file included from /people/ferries/ferespost/SRC/COMMON/result/result.h:25, from /people/ferries/ferespost/SRC/COMMON/algebra/matrix3.h:28: /usr/include/c++/4.1.2/complex: In function `__complex__ float std::__complex_log(__complex__ float)': /usr/include/c++/4.1.2/complex:754: error: `__builtin_clogf' undeclared (first use this function) /usr/include/c++/4.1.2/complex:754: error: (Each undeclared identifier is reported only once for each function it appears in.) /usr/include/c++/4.1.2/complex: In function `__complex__ double std::__complex_log(__complex__ double)': /usr/include/c++/4.1.2/complex:757: error: `__builtin_clog' undeclared (first use this function) /usr/include/c++/4.1.2/complex: In function `__complex__ long double std::__complex_log(__complex__ long double&)': /usr/include/c++/4.1.2/complex:761: error: `__builtin_clogl' undeclared (first use this function) Any workaround? |
From: Vincent F. <vin...@gm...> - 2008-06-05 07:55:33
|
The most curious thing is that the error deals with the only class I'm actually trying to make accessible... I'd have understood if it came from an inclusion class... 2008/6/5, Vincent Ferries <vin...@gm...>: > The library I try to wrap is an open source library called ferespost > used in aerospace calculation. > > I'm currently trying to wrap one of the main classes > postLib::nastran::dataBase which implements > postLib::generic::dataBase. > I generated the wrapping class, addind all the missing include .h and > defining all the missing call_policies so that I haven't any error > generating the .cpp file. > > I compiled it using the sconstruct file I found in the pyEasyBmp > example, modifying it according to my configuration. > > I also tried to comment all the virtual function definitions to see if > it was causing my problem. > > Do I really have to wrap all of the files/classes from the library I'd > like to use to be able to compile, or can I simply use a part of it > like I'm trying to do actually? > > 2008/6/4, Roman Yakovenko <rom...@gm...>: >> On Wed, Jun 4, 2008 at 6:51 PM, Vincent Ferries >> <vin...@gm...> wrote: >>> I tried to comment all the virutal method definitions in my generated >>> .cpp >>> file. >>> If I understand what was said on your link, the linker makes dynamic >>> links for virtual functions which are not redefined in the same file >>> while compiling which causes errors on runtime if it doesn't find >>> them, just like in my case. >>> >>> But without any virtual function left, it should work. >>> >>> I compiled again and still have the same error when importing the >>> module... >> >> If I should guess, than >> or you forgot to add to the link line some of your libraries >> or your new module depends on some other so and cannot find it >> or there is something else :-) >> >> -- >> Roman Yakovenko >> C++ Python language binding >> http://www.language-binding.net/ >> > |
From: Vincent F. <vin...@gm...> - 2008-06-05 07:15:15
|
The library I try to wrap is an open source library called ferespost used in aerospace calculation. I'm currently trying to wrap one of the main classes postLib::nastran::dataBase which implements postLib::generic::dataBase. I generated the wrapping class, addind all the missing include .h and defining all the missing call_policies so that I haven't any error generating the .cpp file. I compiled it using the sconstruct file I found in the pyEasyBmp example, modifying it according to my configuration. I also tried to comment all the virtual function definitions to see if it was causing my problem. Do I really have to wrap all of the files/classes from the library I'd like to use to be able to compile, or can I simply use a part of it like I'm trying to do actually? 2008/6/4, Roman Yakovenko <rom...@gm...>: > On Wed, Jun 4, 2008 at 6:51 PM, Vincent Ferries > <vin...@gm...> wrote: >> I tried to comment all the virutal method definitions in my generated .cpp >> file. >> If I understand what was said on your link, the linker makes dynamic >> links for virtual functions which are not redefined in the same file >> while compiling which causes errors on runtime if it doesn't find >> them, just like in my case. >> >> But without any virtual function left, it should work. >> >> I compiled again and still have the same error when importing the >> module... > > If I should guess, than > or you forgot to add to the link line some of your libraries > or your new module depends on some other so and cannot find it > or there is something else :-) > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Roman Y. <rom...@gm...> - 2008-06-04 17:59:33
|
On Wed, Jun 4, 2008 at 6:51 PM, Vincent Ferries <vin...@gm...> wrote: > I tried to comment all the virutal method definitions in my generated .cpp file. > If I understand what was said on your link, the linker makes dynamic > links for virtual functions which are not redefined in the same file > while compiling which causes errors on runtime if it doesn't find > them, just like in my case. > > But without any virtual function left, it should work. > > I compiled again and still have the same error when importing the module... If I should guess, than or you forgot to add to the link line some of your libraries or your new module depends on some other so and cannot find it or there is something else :-) -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-04 15:51:10
|
I tried to comment all the virutal method definitions in my generated .cpp file. If I understand what was said on your link, the linker makes dynamic links for virtual functions which are not redefined in the same file while compiling which causes errors on runtime if it doesn't find them, just like in my case. But without any virtual function left, it should work. I compiled again and still have the same error when importing the module... 2008/6/4, Vincent Ferries <vin...@gm...>: > 2008/6/4, Gustavo Carneiro <gjc...@gm...>: >> On 04/06/2008, Vincent Ferries <vin...@gm...> wrote: >>> >>> I forgot two words (can't use copy/paste) . >>> Here is the error. >>> >>> ImportError: /people/ferries/ferespost/unittests/ferespost.so: undefined >>> symbol: >>> _ZTIN7postLib7nastran8dataBaseE >>> >>> Any idea of the source of the problem? >> >> >> $ c++filt -t _ZTIN7postLib7nastran8dataBaseE >> typeinfo for postLib::nastran::dataBase >> >> See: >> >> http://www.dbforums.com/archive/index.php/t-352689.html >> >> In which they say one of the possible reasons is the class missing the >> implementation of a virtual method. >> >> Thanks in advance. >>> >>> >>> 2008/6/4, Vincent Ferries <vin...@gm...>: >>> > Ok, I have it working now, just a problem writting the lib name. >>> > But when I try to launch it with the simplest possible example : >>> > >>> > import ferespost >>> > >>> > dataBase = ferespost.dataBase() >>> > >>> > >>> > I get the following error : >>> > >>> > Traceback (most recent call last): >>> > File "test.py", line 1, in ? >>> > import ferespost >>> > ImportError: /people/ferries/ferespost/unittests/ferespost.so: >>> > _ZTIN7postLib7nastran8dataBaseE >>> > >>> > Any idea of what's going wrong? >>> > >>> > This dataBase is defined in the generated .cpp file as >>> > postLib::nastran::dataBase >>> > >>> > 2008/6/4, Vincent Ferries <vin...@gm...>: >>> >> Here is the output : >>> >> >>> >> scons: Reading SConscript files ... >>> >> scons: done reading SConscript files. >>> >> scons: Building targets ... >>> >> g++ -o generated/ferespost.os -c -fPIC -I/usr/lib -I. -ISRC >>> >> -I/usr/include/python2.4 generated/ferespost.cpp >>> >> scons: done building targets. >>> >> >>> >> >>> >> I don't understand why ferespost.os is in the generated command line, >>> >> nor why the .so isn't generated. >>> >> >>> >> 2008/6/4, Roman Yakovenko <rom...@gm...>: >>> >>> On Wed, Jun 4, 2008 at 1:42 PM, Vincent Ferries >>> >>> <vin...@gm...> wrote: >>> >>>> Yes, but in my case it's called .os and not .so and it doesn't >>> >>>> correspond to a share library (see the file command result). >>> >>>> I've double looked my scontruct file and don't catch the error. >>> >>> >>> >>> This is what I missed. I guess for some reason "link" step didn't >>> >>> run. >>> >>> Can you post scons output? >>> >>> >>> >>> >>> >>> -- >>> >>> Roman Yakovenko >>> >>> C++ Python language binding >>> >>> http://www.language-binding.net/ >>> >>> >>> >> >>> > >>> >>> ------------------------------------------------------------------------- >>> Check out the new SourceForge.net Marketplace. >>> It's the best place to buy or sell services for >>> just about anything Open Source. >>> http://sourceforge.net/services/buy/index.php >>> _______________________________________________ >>> pygccxml-development mailing list >>> pyg...@li... >>> https://lists.sourceforge.net/lists/listinfo/pygccxml-development >>> >> >> >> >> -- >> Gustavo J. A. M. Carneiro >> INESC Porto, Telecommunications and Multimedia Unit >> "The universe is always one step beyond logic." -- Frank Herbert >> > |
From: Gustavo C. <gjc...@gm...> - 2008-06-04 15:11:56
|
On 04/06/2008, Vincent Ferries <vin...@gm...> wrote: > > I forgot two words (can't use copy/paste) . > Here is the error. > > ImportError: /people/ferries/ferespost/unittests/ferespost.so: undefined > symbol: > _ZTIN7postLib7nastran8dataBaseE > > Any idea of the source of the problem? $ c++filt -t _ZTIN7postLib7nastran8dataBaseE typeinfo for postLib::nastran::dataBase See: http://www.dbforums.com/archive/index.php/t-352689.html In which they say one of the possible reasons is the class missing the implementation of a virtual method. Thanks in advance. > > > 2008/6/4, Vincent Ferries <vin...@gm...>: > > Ok, I have it working now, just a problem writting the lib name. > > But when I try to launch it with the simplest possible example : > > > > import ferespost > > > > dataBase = ferespost.dataBase() > > > > > > I get the following error : > > > > Traceback (most recent call last): > > File "test.py", line 1, in ? > > import ferespost > > ImportError: /people/ferries/ferespost/unittests/ferespost.so: > > _ZTIN7postLib7nastran8dataBaseE > > > > Any idea of what's going wrong? > > > > This dataBase is defined in the generated .cpp file as > > postLib::nastran::dataBase > > > > 2008/6/4, Vincent Ferries <vin...@gm...>: > >> Here is the output : > >> > >> scons: Reading SConscript files ... > >> scons: done reading SConscript files. > >> scons: Building targets ... > >> g++ -o generated/ferespost.os -c -fPIC -I/usr/lib -I. -ISRC > >> -I/usr/include/python2.4 generated/ferespost.cpp > >> scons: done building targets. > >> > >> > >> I don't understand why ferespost.os is in the generated command line, > >> nor why the .so isn't generated. > >> > >> 2008/6/4, Roman Yakovenko <rom...@gm...>: > >>> On Wed, Jun 4, 2008 at 1:42 PM, Vincent Ferries > >>> <vin...@gm...> wrote: > >>>> Yes, but in my case it's called .os and not .so and it doesn't > >>>> correspond to a share library (see the file command result). > >>>> I've double looked my scontruct file and don't catch the error. > >>> > >>> This is what I missed. I guess for some reason "link" step didn't run. > >>> Can you post scons output? > >>> > >>> > >>> -- > >>> Roman Yakovenko > >>> C++ Python language binding > >>> http://www.language-binding.net/ > >>> > >> > > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > pygccxml-development mailing list > pyg...@li... > https://lists.sourceforge.net/lists/listinfo/pygccxml-development > -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert |
From: Vincent F. <vin...@gm...> - 2008-06-04 15:06:00
|
I forgot two words (can't use copy/paste) . Here is the error. ImportError: /people/ferries/ferespost/unittests/ferespost.so: undefined symbol: _ZTIN7postLib7nastran8dataBaseE Any idea of the source of the problem? Thanks in advance. 2008/6/4, Vincent Ferries <vin...@gm...>: > Ok, I have it working now, just a problem writting the lib name. > But when I try to launch it with the simplest possible example : > > import ferespost > > dataBase = ferespost.dataBase() > > > I get the following error : > > Traceback (most recent call last): > File "test.py", line 1, in ? > import ferespost > ImportError: /people/ferries/ferespost/unittests/ferespost.so: > _ZTIN7postLib7nastran8dataBaseE > > Any idea of what's going wrong? > > This dataBase is defined in the generated .cpp file as > postLib::nastran::dataBase > > 2008/6/4, Vincent Ferries <vin...@gm...>: >> Here is the output : >> >> scons: Reading SConscript files ... >> scons: done reading SConscript files. >> scons: Building targets ... >> g++ -o generated/ferespost.os -c -fPIC -I/usr/lib -I. -ISRC >> -I/usr/include/python2.4 generated/ferespost.cpp >> scons: done building targets. >> >> >> I don't understand why ferespost.os is in the generated command line, >> nor why the .so isn't generated. >> >> 2008/6/4, Roman Yakovenko <rom...@gm...>: >>> On Wed, Jun 4, 2008 at 1:42 PM, Vincent Ferries >>> <vin...@gm...> wrote: >>>> Yes, but in my case it's called .os and not .so and it doesn't >>>> correspond to a share library (see the file command result). >>>> I've double looked my scontruct file and don't catch the error. >>> >>> This is what I missed. I guess for some reason "link" step didn't run. >>> Can you post scons output? >>> >>> >>> -- >>> Roman Yakovenko >>> C++ Python language binding >>> http://www.language-binding.net/ >>> >> > |
From: Vincent F. <vin...@gm...> - 2008-06-04 12:38:32
|
Ok, I have it working now, just a problem writting the lib name. But when I try to launch it with the simplest possible example : import ferespost dataBase = ferespost.dataBase() I get the following error : Traceback (most recent call last): File "test.py", line 1, in ? import ferespost ImportError: /people/ferries/ferespost/unittests/ferespost.so: _ZTIN7postLib7nastran8dataBaseE Any idea of what's going wrong? This dataBase is defined in the generated .cpp file as postLib::nastran::dataBase 2008/6/4, Vincent Ferries <vin...@gm...>: > Here is the output : > > scons: Reading SConscript files ... > scons: done reading SConscript files. > scons: Building targets ... > g++ -o generated/ferespost.os -c -fPIC -I/usr/lib -I. -ISRC > -I/usr/include/python2.4 generated/ferespost.cpp > scons: done building targets. > > > I don't understand why ferespost.os is in the generated command line, > nor why the .so isn't generated. > > 2008/6/4, Roman Yakovenko <rom...@gm...>: >> On Wed, Jun 4, 2008 at 1:42 PM, Vincent Ferries >> <vin...@gm...> wrote: >>> Yes, but in my case it's called .os and not .so and it doesn't >>> correspond to a share library (see the file command result). >>> I've double looked my scontruct file and don't catch the error. >> >> This is what I missed. I guess for some reason "link" step didn't run. >> Can you post scons output? >> >> >> -- >> Roman Yakovenko >> C++ Python language binding >> http://www.language-binding.net/ >> > |
From: Roman Y. <rom...@gm...> - 2008-06-04 10:46:32
|
On Wed, Jun 4, 2008 at 1:42 PM, Vincent Ferries <vin...@gm...> wrote: > Yes, but in my case it's called .os and not .so and it doesn't > correspond to a share library (see the file command result). > I've double looked my scontruct file and don't catch the error. This is what I missed. I guess for some reason "link" step didn't run. Can you post scons output? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2008-06-04 10:37:52
|
On Wed, Jun 4, 2008 at 12:00 PM, Vincent Ferries <vin...@gm...> wrote: > After a LOT of Roman's advices, I'm able to generate the .cpp file > corresponding to a big part of the library I'm currently wrapping. > > I tried to follow the examples given in the website and choosed to use > scons as my building tool. > > Like in pyEasyBmp example, I defined my properties file > (environnement.py) and a scons file. > > Unfortunately, all that's build is a .os, I don't really understand why... What do you expect? When you compile Py++ generated files, you get extension module. After this, you can import it as regular python module. Am I missing something? > Using file command, I get the following line : > ferespost.os: ELF 64-bit LSB relocatable, AMD x86-64, version 1 > (SYSV), not stripped > > Which normally correspond to a .o file if I don't mess up. > > environnement.py mainly contains the following definitions: > boost_path = '/usr/lib' > boost_libs_path = '/usr/lib' > gccxml_path = '/usr/bin/gccxml' > pygccxml_path = '/usr/lib/python2.4/site-packages/pygccxml' > pyplusplus_path = '/usr/lib/python2.4/site-packages/pyplusplus' > ferespost_path = '/people/ferries/ferespost/SRC' > python_libs_path = '/usr/lib/python2.4' > python_include_path = '/usr/include/python2.4' > working_dir = '/people/ferries/ferespost' > generated_files_dir = '/people/ferries/ferespost/generated' > unittests_dir = '/people/ferries/ferespost/unittests' > > The sconstruct file is joined to the present e-mail. > > Thanks again for all your help. > > PS : I'm ever trying to convince my client to publish the wrapper as > an open source library. > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > pygccxml-development mailing list > pyg...@li... > https://lists.sourceforge.net/lists/listinfo/pygccxml-development > -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-04 10:11:30
|
Sorry, here is the sconstruct file content : #! /usr/python # author Vincent FERRIES import os import sys from environment import settings def get_shlibsuffix(): if sys.platform == 'win32': return '.pyd' else: return '.so' def get_ccflags(): if sys.platform == 'win32': return ['/MD', '/EHsc', '/GR'] else: return [] def get_py_ferespost_files(): source_files = filter(lambda s: s.endswith('.cpp'), os.listdir(settings.generated_files_dir)) return map(lambda fname: os.path.join(settings.generated_files_dir, fname), source_files) def get_target(): return os.path.join(settings.unittests_dir, settings.module_name + get_shlibsuffix()) SharedLibrary(target=get_target(), source=[get_py_ferespost_files()], LIBS=['boost_python'], LIB_PATH=[settings.boost_libs_path, settings.python_libs_path], CPPPATH=[settings.boost_path, settings.working_dir, settings.ferespost_path, settings.python_include_path], CCFLAGS=get_ccflags(), SHLIBPREFIX='', SHLIBSUFFIX=get_shlibsuffix()) 2008/6/4, Vincent Ferries <vin...@gm...>: > After a LOT of Roman's advices, I'm able to generate the .cpp file > corresponding to a big part of the library I'm currently wrapping. > > I tried to follow the examples given in the website and choosed to use > scons as my building tool. > > Like in pyEasyBmp example, I defined my properties file > (environnement.py) and a scons file. > > Unfortunately, all that's build is a .os, I don't really understand why... > Using file command, I get the following line : > ferespost.os: ELF 64-bit LSB relocatable, AMD x86-64, version 1 > (SYSV), not stripped > > Which normally correspond to a .o file if I don't mess up. > > environnement.py mainly contains the following definitions: > boost_path = '/usr/lib' > boost_libs_path = '/usr/lib' > gccxml_path = '/usr/bin/gccxml' > pygccxml_path = '/usr/lib/python2.4/site-packages/pygccxml' > pyplusplus_path = '/usr/lib/python2.4/site-packages/pyplusplus' > ferespost_path = '/people/ferries/ferespost/SRC' > python_libs_path = '/usr/lib/python2.4' > python_include_path = '/usr/include/python2.4' > working_dir = '/people/ferries/ferespost' > generated_files_dir = '/people/ferries/ferespost/generated' > unittests_dir = '/people/ferries/ferespost/unittests' > > The sconstruct file is joined to the present e-mail. > > Thanks again for all your help. > > PS : I'm ever trying to convince my client to publish the wrapper as > an open source library. > |
From: Vincent F. <vin...@gm...> - 2008-06-04 09:00:47
|
After a LOT of Roman's advices, I'm able to generate the .cpp file corresponding to a big part of the library I'm currently wrapping. I tried to follow the examples given in the website and choosed to use scons as my building tool. Like in pyEasyBmp example, I defined my properties file (environnement.py) and a scons file. Unfortunately, all that's build is a .os, I don't really understand why... Using file command, I get the following line : ferespost.os: ELF 64-bit LSB relocatable, AMD x86-64, version 1 (SYSV), not stripped Which normally correspond to a .o file if I don't mess up. environnement.py mainly contains the following definitions: boost_path = '/usr/lib' boost_libs_path = '/usr/lib' gccxml_path = '/usr/bin/gccxml' pygccxml_path = '/usr/lib/python2.4/site-packages/pygccxml' pyplusplus_path = '/usr/lib/python2.4/site-packages/pyplusplus' ferespost_path = '/people/ferries/ferespost/SRC' python_libs_path = '/usr/lib/python2.4' python_include_path = '/usr/include/python2.4' working_dir = '/people/ferries/ferespost' generated_files_dir = '/people/ferries/ferespost/generated' unittests_dir = '/people/ferries/ferespost/unittests' The sconstruct file is joined to the present e-mail. Thanks again for all your help. PS : I'm ever trying to convince my client to publish the wrapper as an open source library. |
From: Roman Y. <rom...@gm...> - 2008-04-08 06:52:53
|
On Tue, Apr 8, 2008 at 9:16 AM, Johnson Lu <joh...@op...> wrote: > Hmm.. I can't really recompile my code with the /Zc:wchar_t directive, and I would much rather not deal with writing wrapper code the convert the regular python str into our str type (my manager is hesitant about copying strings around for conversion purpose as he thinks it will be performance sapping). > > What about rebuilding boost so that /Zc:wchar_t is set to NO? Would this be a workable thing? I don't know. I think it worth to try. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Johnson L. <joh...@op...> - 2008-04-08 06:16:45
|
Hmm.. I can't really recompile my code with the /Zc:wchar_t directive, and I would much rather not deal with writing wrapper code the convert the regular python str into our str type (my manager is hesitant about copying strings around for conversion purpose as he thinks it will be performance sapping). What about rebuilding boost so that /Zc:wchar_t is set to NO? Would this be a workable thing? Again, thanks for your help. J.Lu -----Original Message----- From: pyg...@li... [mailto:pyg...@li...] On Behalf Of Roman Yakovenko Sent: Monday, April 07, 2008 9:32 AM To: pygccxml mailing list Subject: [pygccxml-development] Fwd: [pygccxml-commit] string type mismatchbetween python and C++ ---------- Forwarded message ---------- From: Roman Yakovenko <rom...@gm...> Date: Mon, Apr 7, 2008 at 4:31 PM Subject: Re: [pygccxml-commit] string type mismatch between python and C++ To: Johnson Lu <joh...@op...> On Mon, Apr 7, 2008 at 9:55 AM, Johnson Lu <joh...@op...> wrote: > Hello Mr. Yakovenko: Roman is just fine :-) > The compiler I am using is VC 7.1, and we also use the openTop > libraries. > > I am wrapping a class that is part of a large multi-platform product, > and in our product we have some fairly convoluted header includes that, > I think, make strings into different types base on the platform being > compiled on. On VC7.1 simple string became unsigned shorts (heaven only > knows). > > Here is a simple snippet of that function as generated by PY++: > > struct ClassificationOutput_wrapper : ClassificationOutput, bp::wrapper< > ClassificationOutput > { > . > . > . > virtual void setApplicationName( ::ot::String const & > applicationName ) { > if( bp::override func_setApplicationName = this->get_override( > "setApplicationName" ) ) > func_setApplicationName( applicationName ); > else > this->ClassificationOutput::setApplicationName( > applicationName ); > } > void default_setApplicationName( ::ot::String const & > applicationName ) { > ClassificationOutput::setApplicationName( applicationName ); > } > . > . > . > } > BOOST_PYTHON_MODULE(pyplusplus){ > bp::class_< ClassificationOutput_wrapper, boost::noncopyable >( > "ClassificationOutput" ) > .def( bp::init< >() ) > . > . > . > .def( > "setApplicationName" > , &::ClassificationOutput::setApplicationName > , &ClassificationOutput_wrapper::default_setApplicationName > , ( bp::arg("applicationName") ) ) > > > And here is the original .h snippet for the function... > > class ClassificationBuiltinImplDeclSpec ClassificationOutput : public > IClassificationModifiableOutput > { > . > . > . > virtual void setApplicationName(const String& applicationName) ; > > And my test code simply creates a C++ ClassificationOutput object: > > ClassificationOutput mm; > mm.setApplicationName(OPTIER_T("monty python")); > mm.setUserName(OPTIER_T("jclu")); > . > . > . > bpl::object pyCls(boost::ref(mm)); > main_namespace["output"] = pyCls; > > Pass it to Python via name space addition to the python dictionary, then > used a simple python code: > output.setApplicationName("anApplication") # and this line does > not work. > output.getUserName() # returns jclu, so python can read from > C++ > > All seem very straight forward, except not quite so, for me. > > Again, really appreciate your help. Okey, I think I understand the problem and was able to reproduce it. Solution: 1. http://boost.org/doc/libs/1_35_0/libs/python/doc/v2/faq.html#custom_string 2. http://language-binding.net/pyplusplus/documentation/inserting_code.html#insert-code-to-module Explanation: I guess Boost.Python was compiled with "Yes (/Zc:wchar_t)" option turned on. Thus class std::basic_string< unsigned short > and std::basic_string< wchar_t > are 2 different classes. So you will have to define your own string conversion or recompile all your source code with the option. HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Register now and save $200. Hurry, offer ends at 11:59 p.m., Monday, April 7! Use priority code J8TLD2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ pygccxml-development mailing list pyg...@li... https://lists.sourceforge.net/lists/listinfo/pygccxml-development |