Re: Need help with loading .SO file



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.


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
On windows this is usually a missing __declspec(dllexport) but on unix
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
.



Relevant Pages

  • interface tcl to mingw dll which uses a msvc dll
    ... I'm not sure if this is a mingw or tcl problem. ... int ljackCmdHello (ClientData clientData, Tcl_Interp *interp, int ... Ljacktcl_Init(Tcl_Interp* interp) ... unsigned long *servicePackMajor, ...
    (comp.lang.tcl)
  • Re: C extension Clarification
    ... Is that we need to recompile the Tcl Source ... MyCmd (ClientData clientData, Tcl_Interp *interp, int objc, ...
    (comp.lang.tcl)
  • Re: Need help with loading .SO file
    ... int GetText(ClientData clientData, ... int Proc_Init(Tcl_Interp *interp) ... Tcl_CreateCommand(interp, "gettext", GetText, ... But my main problem is compiling this the static TCL library. ...
    (comp.lang.tcl)
  • Re: Need help with loading .SO file
    ... int GetText(ClientData clientData, ... int Proc_Init(Tcl_Interp *interp) ... Tcl_CreateCommand(interp, "gettext", GetText, ... But my main problem is compiling this the static TCL library. ...
    (comp.lang.tcl)
  • Re: Need help with loading .SO file
    ... int GetText(ClientData clientData, ... int Proc_Init(Tcl_Interp *interp) ... Tcl_CreateCommand(interp, "gettext", GetText, ... But my main problem is compiling this the static TCL library. ...
    (comp.lang.tcl)