开发者

How to build a custom TclDevKit prefix file?

开发者 https://www.devze.com 2023-01-31 01:00 出处:网络
I want to use a custom TCL interpreter as the prefix file ofTclDevKit\'s tclapp. I have a TCL interpreter built from the following file:

I want to use a custom TCL interpreter as the prefix file of TclDevKit's tclapp.

I have a TCL interpreter built from the following file:

// file main.cpp
#include <tcl.h>

int
Tcl_AppInit( Tcl_Interp* interp )                    
{
    if ( Tcl_Init( interp ) == TCL_ERROR ) {         
        return TCL_ERROR;                            
    }               
    if ( Tcl_Eval( interp, "puts \"this is my interpreter\"" ) == TCL_ERROR ) {
        return TCL_ERROR;                        
    }
    return TCL_OK;
}

int
main( int argc, char** argv )                        
{
    Tcl_Main( argc, argv, &Tcl_AppInit );
    return 0;
}

I build main.cpp with the following command:

 g++ -Wl,-R/usr/local/lib -L/usr/local/lib -ltcl main.cpp -o myinterp

and get an interpreter myinterp.

How should I m开发者_JS百科odify main.cpp and the g++ command above to be able to pass myinterp as -prefix option of TclDevKit's tclapp?


This is not easy. The prefix files are not conventional executables, but rather full packaged Tcl interpreters including a virtual filesystem containing all the extra bits and pieces that are normally in external files (e.g., encodings, scripts, timezone info on some machines, other resources both textual and binary). This is all packaged up as an entity called a “tclkit” using the sdx tool, and it needs to include a bunch of custom things too (such as the saved-bytecode-file loader package). In short, it's quite a complex build.

Why do you need this? Do you really need C++? Can you rewrite your code so it is in a shared library that Tcl's load command can make available?

0

精彩评论

暂无评论...
验证码 换一张
取 消