Hi,
menth0l wrote:
I wrote a small module with C++ for computing similiarity between
strings. I compiled it on my 32-bit Windows XP machine using MinGW and
SWIG and got a .dll file. It worked like a charm.
Now i need to make it work in Windows 2003 x86_64 envinronment. I
downloaded 64-bit version of MinGW and reproduced exactly the same
steps from 32-bit env, namely:
I have 3 files: Leventsthein.cpp, Levensthein.h (algorithm
implementation) and UtilsXS.cpp (this only exports single function
that uses Levensthein class). Now then:
swig -perl5 -c++ UtilsXS.cpp
Now i have UtilsXS_wrap.cxx, and UtilsXS.pm
g++ -c UtilsXS_wrap.cxx Levensthein.cpp -Ic:\perl64\lib\CORE
g++ -shared UtilsXS_wrap.o Levensthein.o c:\perl64\lib\CORE\perl510.lib -o
UtilsXS.dll
This compiles and links without errors. But when i try to import it in
my .pl file script immediately exits with no messages whatsoever. When
i run it with:
perl -d test.pl
Signal SEGV at UtilsXS.pm line 11
require UtilsXS.pm called at dupa.pl line 2
main::BEGIN() called at UtilsXS.pm line 0
eval {...} called at UtilsXS.pm line 0
Note that this does not happen on my 32-bit envinronment. What could
be the cause? If it helps: i use ActiveState perl v5.10 on both
envinronments.
Is it a 64bit perl? If not, are you compiling everything with -m32?
I think it's impossible for us to help much without more details. Try
running perl in the (C!) debugger and look at the backtrace. Where does
it crash? It could be a bug in your code. In SWIG. In the way your code
interacts with perl, etc. If you cannot do that, try wrapping a
hello-world style function with SWIG on the 64bit environment and if
that works, keep cranking up the complexity of the wrapped library.
On a related note, you may want to simply write the XS for your code
manually. SWIG is fine if it works, but I've been burnt and now try to
stay clear. For C++, you may want to have a look at XS++ (and
correspondingly the documentation of ExtUtils::XSpp and for building
Module::Build::WithXSpp). Caveat: I wrote the latter and contributed to
the former module.
Best reagrds,
Steffen