Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

"Tcl.xs:126: error: initializer element is not constant" while installing Tcl-1.02 in Strawberry Perl v5.10 on Windoze XP

by NateTut (Deacon)
on Jun 02, 2011 at 16:15 UTC ( #907842=perlquestion: print w/ replies, xml ) Need Help??
NateTut has asked for the wisdom of the Perl Monks concerning the following question:

I am receiving the following error while trying to install the Tcl module using the cpan app:

Tcl.xs:126: error: initializer element is not constant dmake: Error code 129, while making 'Tcl.o'

This appears to be a known bug but I haven't found a fix anywhere. I would really like to use Tcl for my current project as well as Strawberry Perl but they are not playing nice together.

Comment on "Tcl.xs:126: error: initializer element is not constant" while installing Tcl-1.02 in Strawberry Perl v5.10 on Windoze XP
Select or Download Code
Re: "Tcl.xs:126: error: initializer element is not constant" while installing Tcl-1.02 in Strawberry Perl v5.10 on Windoze XP
by Gulliver (Monk) on Jun 02, 2011 at 19:04 UTC

    What have you done so far? Have you installed a Tcl environment? Tcl is a seperate interpreter like Perl. Strawberry Perl doesn't come with one like ActiveState Perl. As much as I like Strawberry Perl, ActiveState has made it painless to get Tcl working because the executable gets installed at the same time as Perl.

      Yes, I have Tcl installed and tclsh is in the path. I am fiddling with Tcl.xs now to see if I can get it to compile (and hopefully not break the module too badly)

        The offending line in Tcl.xs is:

        static int (* tclKit_AppInit)(Tcl_Interp *) = Tcl_Init;

        Tcl_Init is defined thusly:

        void Tcl_Init(interp) Tcl interp CODE: if (!initialized) { return; } if (tclKit_AppInit(interp) != TCL_OK) { croak(Tcl_GetStringResult(interp)); } Tcl_CreateObjCommand(interp, "::perl::Eval", Tcl_EvalInPerl, (ClientData) NULL, NULL);


        I'm not well versed in xs so I'm not sure what the issue is.

Re: "Tcl.xs:126: error: initializer element is not constant" while installing Tcl-1.02 in Strawberry Perl v5.10 on Windoze XP
by vkon (Deacon) on Jun 03, 2011 at 09:41 UTC
    Sorry for this error, it should have been fixed already, but it isn't :(
    I hope to release new version this weekend.

    Meanwhile, here is a patch for 1.02 that should fix the problem

    diff -rbu Tcl-1.02/Makefile.PL Tcl-1.02-fix/Makefile.PL --- Tcl-1.02/Makefile.PL Fri Feb 11 12:00:35 2011 +++ Tcl-1.02-fix/Makefile.PL Fri Jun 3 13:37:45 2011 @@ -196,6 +196,9 @@ if ($^O eq 'MSWin32') { $tclver=~s/\.//; $defs .= " -DTCL_LIB_FILE=\\\"tcl$tclver.dll\\\"" if $usestub +s; + + # Use g++ if using strawberry perl + @extraargs = (CC => 'g++') if $^X =~ /strawberry/; } elsif ($^O eq 'freebsd') { $tclver=~s/\.//; @@ -272,11 +275,6 @@ } } -sub MY::libscan { - my($self, $path) =@_; - return '' if $path =~ /\.pl$/i; - return $path; -} BEGIN { # compatibility with older versions of MakeMaker @@ -299,3 +297,20 @@ ExtUtils::MakeMaker::WriteMakefile(%arg); }; } + +package MY; # so that "SUPER" works right +sub libscan { + my($self, $path) =@_; + return '' if $path =~ /\.pl$/i; + return $path; +} + +sub c_o { + my $inherited = shift->SUPER::c_o(@_); + + # Fix for strawberry perl build + $inherited =~ s/\bgcc\b/\$(CCCMD)/g if $^X =~ /strawberry/; + + $inherited; +} + diff -rbu Tcl-1.02/Tcl.xs Tcl-1.02-fix/Tcl.xs --- Tcl-1.02/Tcl.xs Fri Feb 11 12:00:35 2011 +++ Tcl-1.02-fix/Tcl.xs Fri Jun 3 13:35:09 2011 @@ -602,7 +602,7 @@ STRLEN len; char *s = SvPV(sv, len); char *end = s + len; - while ((nul_start = memchr(s, '\300', len))) { + while ((nul_start = (char*)memchr(s, '\300', len))) { if (nul_start + 1 < end && nul_start[1] == '\200') { /* found it */ nul_start[0] = '\0'; @@ -692,7 +692,7 @@ char *s = SvPV(sv_copy, len); char *nul; - while ((nul = memchr(s, '\0', len))) { + while ((nul = (char*)memchr(s, '\0', len))) { STRLEN i = nul - SvPVX(sv_copy); s = SvGROW(sv_copy, SvCUR(sv_copy) + 2); nul = s + i; @@ -979,8 +979,8 @@ MODULE = Tcl PACKAGE = Tcl PREFIX = Tcl_ SV * -Tcl__new(class = "Tcl") - char * class +Tcl__new(Class = "Tcl") + char * Class CODE: RETVAL = newSV(0); /* @@ -995,7 +995,7 @@ (void) hv_store(hvInterps, (const char *) &interp, sizeof(Tcl), &PL_sv_undef, 0); } - sv_setref_pv(RETVAL, class, (void*)interp); + sv_setref_pv(RETVAL, Class, (void*)interp); } OUTPUT: RETVAL
      No problem, bugs happen. I appreciate the effort you guys put into great stuff like this, How do I apply the patch? I did find it online too, but I didn't know what do do with it!
        applying a patch means to use a "patch" utility.
        In this particular case - it is even possible to do manual edit of the text,
        but nevermind -

        there is simpler way - please get patched distribution at http://vadrer.org/files-exchange/Tcl-1.02-fix.zip

        Regards,
        Vadim

        I'm a little slow sometimes, but I finally got it! Thanks for your help.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-09-23 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (218 votes), past polls