Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how can I load the dll

28 views
Skip to first unread message

zou...@zte.com.cn

unread,
Feb 20, 2012, 8:24:38 AM2/20/12
to
I am learning Tcl.

as an exercise,I want to write C code for Tcl application.

The code is copied from the help document as below:

--------------------------------------------------------------------------
#include <tcl.h>
#include <stdio.h>
static int fooCmd(ClientData clientData,
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) {
printf("called with %d arguments\n", objc);
return TCL_OK;
}
int Foo_Init(Tcl_Interp *interp) {
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
return TCL_ERROR;
}
printf("creating foo command");
Tcl_CreateObjCommand(interp, "foo", fooCmd, NULL, NULL);
return TCL_OK;
}

-----------------------------------------------------------------------------
I compile it by VS 2005 C++ and create the dll success.

but when I load the dll in tkcon ,it is alwayes report error as
below :
-------------------------------------------------------
load d:/tcl/test/mydll/Foo_Init.dll
can't find the procedure Foo_Init
------------------------------------------------------

could you tell me what wrong with my operating . If the dll has some
fault?

thanks a lot .

Georgios Petasis

unread,
Feb 20, 2012, 8:46:33 AM2/20/12
to
Try adding:

extern "C" DLLEXPORT int Foo_Init(...


George

zou...@zte.com.cn

unread,
Feb 21, 2012, 6:36:56 PM2/21/12
to
The result is same as before.

VS 2005 C++ provide the function compilling as C code .

Do you think I should try the Turbo c or SWIG.

Georgios Petasis

unread,
Feb 22, 2012, 3:45:32 AM2/22/12
to
Check with dependency walker (http://www.dependencywalker.com/) whether
the function is exported from the DLL, and that its name matches what
Tcl expects.

George

zou...@zte.com.cn

unread,
Feb 23, 2012, 6:55:50 PM2/23/12
to
Thank you very much .this tools is very nice .

A important clue be found by useing the tools ,and the problem have
been solved.

Many thanks

GN

unread,
Feb 24, 2012, 3:26:36 AM2/24/12
to
On Feb 24, 12:55 am, zou...@zte.com.cn wrote:
> A important clue be found by useing the tools ,and the problem have
> been solved.

an interested reader from the last row wonders what the actual problem
was;
please post the diagnosis and solution such that others might benefit
from this.

zou...@zte.com.cn

unread,
Feb 26, 2012, 10:23:01 PM2/26/12
to
I am so sorry for what I do.

The last result is as below:

extern "C" __declspec(dllexport) int Foo_Init (just as George
said )

or

using SWIG with VC++,just follow the step described in MSDN.

I havn't the MSDN in my home.

so I can't described clearly.

zou...@zte.com.cn

unread,
Feb 26, 2012, 10:25:52 PM2/26/12
to
I apologize again for my negligence.
0 new messages