Artifacts Associated With Ticket 3097212fffffffffffffffffffffffffffffffff
Ticket change [286016c5e1] (rid 88688) by abhayh on 2010-10-28 09:16:28:
- assignee initialized to: "mdejong"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hi everyone. I am using MS VS 2005 to write a simple TCL extension. Below is my code. #include<tcl.h> #include<iostream> using namespace std; int Add_Nums (ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv); //ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv) int DLLEXPORT Add_Init(Tcl_Interp *interp) { if(Tcl_InitStubs(interp,"8.4",0)==NULL){ return TCL_ERROR; } if (Tcl_PkgProvide(interp, "add", "1.1") == TCL_ERROR) { return TCL_ERROR; } Tcl_Command Tcl_CreateObjCommand(interp,"add",Add_Nums,NULL,NULL); return TCL_OK; } int Add_Nums (ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv) { int adding(int no1,int no2); return TCL_OK; } int adding(int no1,int no2) { int sum =0; cout<<"Enter the two numbers:"<<endl; cin>>no1>>no2; cout<<"Sum is "<<no1+no2<<endl; return(sum); } When i build this , its giving me " Too many Initiallizers " pointing at Tcl_CreateObjCommand() line. How do i resolve this? Thanks - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "abhayh"
- subsystem initialized to: "70. Sample Extension"
- title initialized to:
"Too many Initiallizers " error with Tcl_CreateObjCommand()
- type initialized to: "Bug"
Ticket change [58390aa3d1] (rid 117764) by ferrieux on 2010-10-28 18:53:38:
- icomment:
That's a C typo. You don't want "Tcl_Command" just before the call to Tcl_CreateObjCommand. Before submitting a bug report, try identifying the failing part. A compile error is hardly the Tcl library's responsibility.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [f525874934] (rid 130059) by ferrieux on 2010-10-28 18:53:39:
- closedate changed to: "2010-10-28T11:53:39"
- closer changed to: "ferrieux"
- resolution changed to: "Invalid"
- status changed to: "Closed"
Ticket change [d8d13f0dd5] (rid 107511) by abhayh on 2010-10-28 18:58:14:
- icomment:
Sorry about the typo.But in my actual it's Tcl_CreateObjCommand(), i have rechecked it. If this is not the right place to post the problem, can you please link me to the proper one & close this thread. Thanks
- login: "abhayh"
- mimetype: "text/plain"
- username: "abhayh"
- icomment:
Ticket change [7de72fc375] (rid 97309) by ferrieux on 2010-10-28 19:08:58:
- icomment:
Then paste your original !
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [be502eeb4c] (rid 102052) by abhayh on 2010-10-28 19:14:10:
- icomment:
#include<tcl.h> #include<iostream> using namespace std; int Add_Nums (ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv); //ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv) int DLLEXPORT Add_Init(Tcl_Interp *interp) { #ifdef USE_TCL_STUBS Tcl_InitStubs(interp, "8.4", 0); #endif if (Tcl_PkgProvide(interp, "8.4", "1.1") == TCL_ERROR) { return TCL_ERROR; } Tcl_CreateObjCommand(interp,"add",Add_Nums,NULL,NULL); return TCL_OK; } int Add_Nums (ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv) { int adding(int no1,int no2); return TCL_OK; } int adding(int no1,int no2) { int sum =0; cout<<"Enter the two numbers:"<<endl; cin>>no1>>no2; cout<<"Sum is "<<no1+no2<<endl; return(sum); } Well, it's now showing me few linker errors. I tried to debug it , but couldn't find a way. It's getting compiled but has few unresolved symbol issues. These are the errors. 1> : error LNK2001: unresolved external symbol _tclStubsPtr 1> : error LNK2019: unresolved external symbol _Tcl_InitStubs referenced in function "int __cdecl Add_Init(struct Tcl_Interp *)" (?Add_Init@@YAHPAUTcl_Interp@@@Z) 1> : fatal error LNK1120: 2 unresolved externals 1> - 3 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== - login: "abhayh"
- mimetype: "text/plain"
- username: "abhayh"
- icomment:
Ticket change [0c095cd881] (rid 114107) by ferrieux on 2010-10-28 19:48:38:
- assignee changed to: "kennykb"
- icomment:
Changing the title, and the assignee, accordingly.
- login: "ferrieux"
- mimetype: "text/plain"
- title changed to: "Linking extension with stubs"
- username: "ferrieux"
Ticket change [c5e0068f45] (rid 121659) by dkf on 2010-10-28 20:32:37:
- icomment:
Solution part #1: You need to link with the tclstub library. Solution part #2: The Add_Init function needs to have 'extern "C"' linkage or [load] will never be able to do anything with the lib. Solution part #3: Tcl_PkgProvide's second argument needs to be the package name (e.g., "add" in this case).
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [8254eb42ed] (rid 117218) by abhayh on 2010-10-28 21:13:55:
- icomment:
>>Solution part #2: The Add_Init function needs to have 'extern "C"' linkage or [load] will never be able to do anything with the lib. Solution part #3: Tcl_PkgProvide's second argument needs to be the package name (e.g., "add" in this case). I edited the code as above. #include<tcl.h> #include<iostream> using namespace std; #ifndef STATIC_BUILD #if defined(_MSC_VER) # define EXPORT(a,b) __declspec(dllexport) a b # define DllEntryPoint DllMain #else # if defined(__BORLANDC__) # define EXPORT(a,b) a _export b # else # define EXPORT(a,b) a b # endif #endif #endif int Add_Nums (ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv); //ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv) int DLLEXPORT extern "C" int Add_Init(Tcl_Interp *interp) { #ifdef USE_TCL_STUBS Tcl_InitStubs(interp, "8.4", 0); #endif if (Tcl_PkgProvide(interp, "add", "1.1") == TCL_ERROR) { return TCL_ERROR; } Tcl_CreateObjCommand(interp,"add",Add_Nums,NULL,NULL); return TCL_OK; } int Add_Nums (ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv) { int adding(int no1,int no2); return TCL_OK; } int adding(int no1,int no2) { int sum =0; cout<<"Enter the two numbers:"<<endl; cin>>no1>>no2; cout<<"Sum is "<<no1+no2<<endl; return(sum); } >>Solution part #1: You need to link with the tclstub library. How do i link with tclstub library?I have added tclstub84.lib in the "Linker"> Additioinal Library Dependencies.Is this the right way? As of now ,I am getting the following error. 1> error LNK2001: unresolved external symbol _tclStubsPtr 1> error LNK2019: unresolved external symbol _Tcl_InitStubs referenced in function _Add_Init 1> fatal error LNK1120: 2 unresolved externals - login: "abhayh"
- mimetype: "text/plain"
- username: "abhayh"
- icomment:
Ticket change [0b52854de0] (rid 113962) by abhayh on 2010-10-29 15:44:58:
- icomment:
I am able to resolve the issue. Thanks a lot :) Now i'm having issues loading the dll. % load Name_of_Dll_file.dll Pkgname gives me "Cannot find proc Name_of_Dll_file_init .. I have few querries. 1. Should the Dll name & the Cpp source code name should be the same? 2.If my dll name is mydll.dll , then the name of init function should be mydll_init , is it ? 3.What should be the package name?
- login: "abhayh"
- mimetype: "text/plain"
- username: "abhayh"
- icomment:
Ticket change [72ec0c55ad] (rid 104951) by ferrieux on 2010-10-29 15:54:56:
- icomment:
Maybe it 's a bit late to say this ... but this discussion doesn't quite belong there. Next time, use the comp.lang.tcl newsgroup, where you'll reach a larger audience both of experts and followers.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [35b825c54a] (rid 106987) by ferrieux on 2010-10-29 16:12:22:
- icomment:
allow_comments - 1
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment: