Skip to content
Tcl Source Code History Of Ticket 3097212fffffffff
Login

History Of Ticket 3097212fffffffff

Artifacts Associated With Ticket 3097212fffffffff

  1. Ticket change [286016c5e1] (rid 88688) by abhayh on 2010-10-28 09:16:28:

    1. assignee initialized to: "mdejong"
    2. cmimetype initialized to: "text/plain"
    3. 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
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "abhayh"
    10. subsystem initialized to: "70. Sample Extension"
    11. title initialized to:
      "Too many Initiallizers " error with Tcl_CreateObjCommand() 
      
    12. type initialized to: "Bug"
  2. Ticket change [58390aa3d1] (rid 117764) by ferrieux on 2010-10-28 18:53:38:

    1. 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.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  3. Ticket change [f525874934] (rid 130059) by ferrieux on 2010-10-28 18:53:39:

    1. closedate changed to: "2010-10-28T11:53:39"
    2. closer changed to: "ferrieux"
    3. resolution changed to: "Invalid"
    4. status changed to: "Closed"
  4. Ticket change [d8d13f0dd5] (rid 107511) by abhayh on 2010-10-28 18:58:14:

    1. 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
      
      
      
    2. login: "abhayh"
    3. mimetype: "text/plain"
    4. username: "abhayh"
  5. Ticket change [7de72fc375] (rid 97309) by ferrieux on 2010-10-28 19:08:58:

    1. icomment:
      Then paste your original !
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Ticket change [be502eeb4c] (rid 102052) by abhayh on 2010-10-28 19:14:10:

    1. 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 ==========
      
      
      
    2. login: "abhayh"
    3. mimetype: "text/plain"
    4. username: "abhayh"
  7. Ticket change [0c095cd881] (rid 114107) by ferrieux on 2010-10-28 19:48:38:

    1. assignee changed to: "kennykb"
    2. icomment:
      Changing the title, and the assignee, accordingly.
      
      
    3. login: "ferrieux"
    4. mimetype: "text/plain"
    5. title changed to: "Linking extension with stubs"
    6. username: "ferrieux"
  8. Ticket change [c5e0068f45] (rid 121659) by dkf on 2010-10-28 20:32:37:

    1. 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).
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  9. Ticket change [8254eb42ed] (rid 117218) by abhayh on 2010-10-28 21:13:55:

    1. 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
      
      
      
      
    2. login: "abhayh"
    3. mimetype: "text/plain"
    4. username: "abhayh"
  10. Ticket change [0b52854de0] (rid 113962) by abhayh on 2010-10-29 15:44:58:

    1. 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?
      
      
    2. login: "abhayh"
    3. mimetype: "text/plain"
    4. username: "abhayh"
  11. Ticket change [72ec0c55ad] (rid 104951) by ferrieux on 2010-10-29 15:54:56:

    1. 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.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  12. Ticket change [35b825c54a] (rid 106987) by ferrieux on 2010-10-29 16:12:22:

    1. icomment:
      
      
      allow_comments - 1
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"