Re: Need help with loading .SO file
- From: Tobias Hippler <hi@xxxxxxxxx>
- Date: Wed, 30 Aug 2006 09:17:32 +0200
ShurikAg@xxxxxxxxx wrote:
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
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
Where am I wrong????
Hi,
you have to add extern "C" in front of the definition of Proc_Init:
extern "C" int Proc_Init(Tcl_Interp *interp)
{
if (Tcl_InitStubs(interp, "8.3", 0) == NULL) {
return TCL_ERROR;
...
...
}
Otherwise the symbols of your *.so get mangled (c++ - style) and the runtime loader can't find the symbol "Proc_Init".
BTW if you don't have to use C++, you can simply rename your file to "Proc.c". This way the C compiler is used and no name mangling occurrs.
Cheers,
Tobi
.
- Follow-Ups:
- Re: Need help with loading .SO file
- From: ShurikAg
- Re: Need help with loading .SO file
- From: Donal K. Fellows
- Re: Need help with loading .SO file
- References:
- Need help with loading .SO file
- From: ShurikAg
- Need help with loading .SO file
- Prev by Date: Package Requires CSV?
- Next by Date: Re: Package Requires CSV?
- Previous by thread: Re: Need help with loading .SO file
- Next by thread: Re: Need help with loading .SO file
- Index(es):
Relevant Pages
|