SilvioCVdeAlmeida <[EMAIL PROTECTED]> writes: >Hello, > >How suitable is h2xs for generating C++Perl bindings?
Not very. A typical C++ .h file has all kinds of constructs h2xs isn't expecting. (namespaces, and overloaded functions, inline members,...) >I couldn't manage >it to work as I expected. > >I'm trying to build a Perl module to access a C++ library, closely >following "Extension based on .h and .c files" from h2xs manpage: > >1. start dirs: > h2xs -Afn Pack >2. copy .h and .c (.cc in my case) to Pack/ >3. create extension: > h2xs -Oxan Pack head_1.h head2.h >4. archive and test: > cd Pack > perl Makefile.PL > make dist > make > make test > >It breaks in make test, because generated Pack.c (-- not Pack.cc as I >wanted --) The snag is that there are too many conventions .cc is new to me in fact! .cxx and .cpp are normal ones and even (on case sensative systems .C). But most C++ compilers can have C++-ness forced upon them. >ask for C compilation, which do not find iostream, string, >and other standard C++ headers. That bit is faily easy. You need to override CC as g++ (or whatever your C++ compiler is called - WriteMakefile( 'CC' => 'g++', 'LD => 'g++', ...); Similarly for Win32 with VC++ the is a command line flag to 'cl' which says to treat source as C++. Note that gcc's -x c++ is not quite enough as it only affects the compile not the link. > >Any help would be very appreciated. > >Silvio