Joe English | 2 Jul 17:54

Re: Tcl/Tk 8.6a1 RELEASED


Rene Zaumseil wrote:
> Joe English wrote:
> > [...]
> > Note that for kit executables you must generally link
> > against the stub library *in addition* to the main library,
> > not instead of it.
>
> Until and including 8.5.3 I do not need the libtclstub* library.

The new rules are: code compiled with -DUSE_TCL_STUBS
must link against libtclstub.  Code compiled without
-DUSE_TCL_STUBS must link against libtcl.  If you have
some code compiled with and some code compiled without
in the same executable, then you must link against both
libraries.

(Those are actually the old rules, too, although things
would sometimes still link anyway even if they were not
followed.)

> > If you put libtk, libtkstub, libtcl, and libtclstub towards the
> > end of the link line -- after extension libraries but before
> > system libraries like libm, libdl, libX11, etc. -- in that order,
> > it should link correctly no matter how things were compiled.
>
> The link stage is successfull. But I get a segmentation fault in
> loading the first extension (vlerq) in the first line of:
>
> DLLEXPORT int Vlerq_Init (Tcl_Interp *interp) {
>     if (!MyInitStubs(interp) || Tcl_PkgRequire(interp, "Tcl", "8.4", 0) ==
> NULL)
>         return TCL_ERROR;
>     [...]
> }
>
> MyInitStubs(interp) is #defined to '1'.

This is not correct.  It will only work if the extension
is compiled without -DUSE_TCL_STUBS.  If it's compiled
with -DUSE_TCL_STUBS, it will segfault at the call to
Tcl_PkgRequire().  That sounds like the symptom you're seeing.

Change this to:

    DLLEXPORT int Vlerq_Init (Tcl_Interp *interp)
    {
	if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
	    return TCL_ERROR;
	}
	[... rest of extension initialization ...]
    }

and it will work properly whether compiled with
or without -DUSE_TCL_STUBS.  (Tcl_InitStubs() is
a macro; if stubs are disabled, it just does some
error checking and other than that is a no-op.)

--Joe English

  jenglish@...

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08

Gmane