Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Can't compile XS code

by nglenn (Beadle)
on Oct 26, 2012 at 19:02 UTC ( #1001132=perlquestion: print w/ replies, xml ) Need Help??
nglenn has asked for the wisdom of the Perl Monks concerning the following question:

I am using Windows 7 64 bit, Strawberry Perl 5.16.1. I have another computer with seemingly the same configuration that does not have the same problem.

I was trying to compile a module with XS code and it spat all sorts of compilation errors at me. Since I had heard that 5.16 had shipped with the developer release of MakeMaker, I thought that might be the problem, so I did tried to install the last release of MakeMaker (6.62). However, I got the same errors during the testing. Can anyone help me figure out why I have the errors given below during testing of MakeMaker, more specifically during any XS compilation?

t/VERSION_FROM.t .......... ok t/WriteEmptyMakefile.t .... ok t/writemakefile_args.t .... ok t/xs.t .................... 3/5 t/xs.t .................... 4/5 # Failed test ' make exited normall +y' # at t/xs.t line 53. # got: '65280' # expected: '0' # cp lib/XS/Test.pm blib\lib\XS\Test.pm # C:\strawberry\perl\bin\perl.exe C:\strawberry\perl\lib\ExtUtils\xsub +pp -typem ap C:\strawberry\perl\lib\ExtUtils\typemap Test.xs > Test.xsc && C:\s +trawberry\ perl\bin\perl.exe -MExtUtils::Command -e mv -- Test.xsc Test.c # gcc -c -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_ +SCRIPTS -D PERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-bi +tfields -s -O2 -DVERSION=\"1.01\" -DXS_VERSION=\"1.01\" "-IC:\strawberr +y\perl\lib \CORE" Test.c # Running Mkbootstrap for XS::Test () # C:\strawberry\perl\bin\perl.exe -MExtUtils::Command -e chmod -- 644 +Test.bs # C:\strawberry\perl\bin\perl.exe -MExtUtils::Mksymlists \ # -e "Mksymlists('NAME'=>\"XS::Test\", 'DLBASE' => 'Test', 'DL_FU +NCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);" # dlltool --def Test.def --output-exp dll.exp # g++ -o blib\arch\auto\XS\Test\Test.dll -Wl,--base-file -Wl,dll.base +-mdll -s - L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib" Test.o C:\str +awberry\pe rl\lib\CORE\libperl516.a -lmoldname -lkernel32 -luser32 -lgdi32 -lwins +pool -lcom dlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_ +32 -lmpr - lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 dll.exp # Test.o:Test.c:(.text+0x9): undefined reference to `_imp__Perl_get_co +ntext' # Test.o:Test.c:(.text+0x6f): undefined reference to `_imp__Perl_sv_2i +v_flags' # Test.o:Test.c:(.text+0xc4): undefined reference to `_imp__Perl_sv_se +tiv' # Test.o:Test.c:(.text+0xd9): undefined reference to `_imp__Perl_mg_se +t' # Test.o:Test.c:(.text+0x11a): undefined reference to `_imp__Perl_sv_n +ewmortal' # Test.o:Test.c:(.text+0x13c): undefined reference to `_imp__Perl_croa +k_xs_usage ' # Test.o:Test.c:(.text+0x149): undefined reference to `_imp__Perl_get_ +context' # Test.o:Test.c:(.text+0x1a4): undefined reference to `_imp__Perl_xs_a +piversion_ bootcheck' # Test.o:Test.c:(.text+0x1c7): undefined reference to `_imp__Perl_xs_v +ersion_boo tcheck' # Test.o:Test.c:(.text+0x1ea): undefined reference to `_imp__Perl_newX +S' # Test.o:Test.c:(.text+0x216): undefined reference to `_imp__Perl_call +_list' # collect2: ld returned 1 exit status # dmake: Error code 129, while making 'blib\arch\auto\XS\Test\Test.dl +l' t/xs.t .................... 5/5 # Failed test ' make test exited no +rmally' # at t/xs.t line 57. # got: '65280' # expected: '0' # dlltool --def Test.def --output-exp dll.exp # g++ -o blib\arch\auto\XS\Test\Test.dll -Wl,--base-file -Wl,dll.base +-mdll -s - L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib" Test.o C:\str +awberry\pe rl\lib\CORE\libperl516.a -lmoldname -lkernel32 -luser32 -lgdi32 -lwins +pool -lcom dlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_ +32 -lmpr - lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 dll.exp # Test.o:Test.c:(.text+0x9): undefined reference to `_imp__Perl_get_co +ntext' # Test.o:Test.c:(.text+0x6f): undefined reference to `_imp__Perl_sv_2i +v_flags' # Test.o:Test.c:(.text+0xc4): undefined reference to `_imp__Perl_sv_se +tiv' # Test.o:Test.c:(.text+0xd9): undefined reference to `_imp__Perl_mg_se +t' # Test.o:Test.c:(.text+0x11a): undefined reference to `_imp__Perl_sv_n +ewmortal' # Test.o:Test.c:(.text+0x13c): undefined reference to `_imp__Perl_croa +k_xs_usage ' # Test.o:Test.c:(.text+0x149): undefined reference to `_imp__Perl_get_ +context' # Test.o:Test.c:(.text+0x1a4): undefined reference to `_imp__Perl_xs_a +piversion_ bootcheck' # Test.o:Test.c:(.text+0x1c7): undefined reference to `_imp__Perl_xs_v +ersion_boo tcheck' # Test.o:Test.c:(.text+0x1ea): undefined reference to `_imp__Perl_newX +S' # Test.o:Test.c:(.text+0x216): undefined reference to `_imp__Perl_call +_list' # collect2: ld returned 1 exit status # dmake: Error code 129, while making 'blib\arch\auto\XS\Test\Test.dl +l' # Looks like you failed 2 tests of 5. t/xs.t .................... Dubious, test returned 2 (wstat 512, 0x200 +) Failed 2/5 subtests

EDIT: The problem was that I had another distribution of MINGW on my path. Once that was removed, everything worked smoothly.

Comment on Can't compile XS code
Download Code
Re: Can't compile XS code
by syphilis (Canon) on Oct 26, 2012 at 22:57 UTC
    undefined reference to `_imp__Perl_get_context'

    I would think that symbol (and all of the others mentioned) should have been resolved by C:\strawberry\perl\lib\CORE\libperl516.a, to which you are apparently linking.
    Run objdump -t C:\strawberry\perl\lib\CORE\libperl516.a >dump.txt and check that `_imp__Perl_get_context' can be found in the output that was sent to dump.txt.
    Looking at my build of Strawberry 5.12, it looks like those symbols might be prefixed by 2 (not one) underscores. However, I don't know if such a discrepancy would matter anyway.

    What does perl -V output. This is strange ... it shouldn't be happening.

    Perhaps simply re-installing Strawberry Perl might fix the problem.

    Cheers,
    Rob

      objdump gives me a whole bunch of:

      objdump: dknisxxxxx.o: File format not recognized

      perl -V gives me:

      Summary of my perl5 (revision 5 version 16 subversion 1) configuration +: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x64-multi-thread uname='Win32 strawberry-perl 5.16.1.1 #1 Thu Aug 9 07:49:27 2012 +x64' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL +_TEXTMODE_ SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasi +ng -mms-bi tfields', optimize='-s -O2', cppflags='-DWIN32' ccversion='', gccversion='4.6.3', gccosandvers='' intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='lo +ng long', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE" -L"C:\straw +berry\c\li b"' libpth=C:\strawberry\c\lib C:\strawberry\c\x86_64-w64-mingw32\lib libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 +-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm + -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdl +g32 -ladva pi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lw +inmm -lver sion -lodbc32 -lodbccp32 -lcomctl32 libc=, so=dll, useshrplib=true, libperl=libperl516.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE +" -L"C:\st rawberry\c\lib"' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PL_OP_SLAB +_ALLOC USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF Built under MSWin32 Compiled at Aug 9 2012 07:55:51 @INC: C:/strawberry/perl/site/lib/MSWin32-x64-multi-thread C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .

        objdump: dknisxxxxx.o: File format not recognized

        Then that's your problem ... or at least *one* problem that needs to be fixed.

        Could that libperl516.a that's being found be a 32-bit version of libperl516.a ? The error messages from objdump would fit such a scenario.
        Compare it to the libperl516.a that's on the other machine you mentioned. They should be identical (obviously), right down to the Digest::MD5 signatures, if they're the same builds of Strawberry Perl.

        Afterthought: If that libperl516.a is 64-bit, then another possibility is that you've just run a 32-bit version of objdump on it. That would also fit the objdump errors you reported.

        Cheers,
        Rob
Re: Can't compile XS code
by syphilis (Canon) on Oct 27, 2012 at 07:05 UTC
    It has just dawned on me that the compilation failures quoted are occurring during 'dmake test' and not 'dmake' as I had assumed. (My mistake - it's pretty obvious that 'dmake test' is under way.)

    Normally, by the time we get to 'dmake test', all compilation has been done - and it's uncommon to see compilation being carried out during the 'dmake test' stage. What module is it (in your original post) that you are trying to build ?

    Cheers,
    Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1001132]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-11-28 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (195 votes), past polls