Overview
| Artifact ID: | 8254eb42ed73c7d5e9f3d003dd975e9390725e23 |
|---|---|
| Ticket: | 3097212fffffffffffffffffffffffffffffffff
Linking extension with stubs |
| User & Date: | abhayh on 2010-10-28 21:13:55 |
Changes
- 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"