Re: Need help with loading .SO file
- From: Michael Schlenker <schlenk@xxxxxxxxxxxxxxxx>
- Date: Tue, 29 Aug 2006 20:03:29 +0200
ShurikAg@xxxxxxxxx schrieb:
There is Proc.cpp:
#include "tcl.h"
//#pragma comment(lib,"C:/TCL/lib/tcl84.lib")
int GetText(ClientData clientData,
Tcl_Interp *interp,
int argc, char *argv[]);
int Proc_Init(Tcl_Interp *interp)
{
if (Tcl_InitStubs(interp, "8.3", 0) == NULL) {
return TCL_ERROR;
}
Tcl_CreateCommand(interp, "gettext", GetText,
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
Tcl_PkgProvide(interp, "gettext", "1.1");
return TCL_OK;
}
int GetText(ClientData clientData, Tcl_Interp *interp, int argc, char
*argv[])
{
sprintf(interp->result, "%d", 25);
return TCL_OK;
}
Compiling: gcc -fPIC -c Proc.cpp
Linking: gcc -shared -o Proc.so Proc.o
I would have suspected at least something like libtclstub8.3.a in the
link line, along with a -DUSE_TCL_STUBS in the compile line.
On windows this is usually a missing __declspec(dllexport) but on unix
Entering to TCL: wish8.3
Trying to load the Library: % load
/nfs/iil/disks/home05/aagulya/TCL/Proc.so
... and getting the error: couldn't find procedure Proc_Init
it should work. Btw. wish 8.3 is quite old..., unless you have a good
reason to stay with Tcl 8.3 you should try to use a recent Tcl like Tcl
8.4.13
Much of your Tcl API usage style is also quite dated:
1. direct access to interp->result is frowned upon, don't do it
2. Tcl_CreateCommand() has a more modern Tcl_CreateObjCommand() version
which uses the dual ported Tcl_Obj* instead of strings for everything.
You could start from the sampleextension as a better example how to get
a basic extension working.
See http://wiki.tcl.tk/sampleextension
Michael
.
- References:
- Need help with loading .SO file
- From: ShurikAg
- Need help with loading .SO file
- Prev by Date: ps2pdf13 translation spoils the eps file from saving the canvas image
- Next by Date: Re: Creating a statically compiled Expect
- Previous by thread: Need help with loading .SO file
- Next by thread: Re: Need help with loading .SO file
- Index(es):
Relevant Pages
|