I want to create a loadable dll of some of my tcl methods. But i am not getting how to do this. For that i have taken a simple example of tcl api which adds two numbers and prints the sum. Now i want to create a loadable dll for this to export this tcl functionality. But i am not getting how to do it in visual studio. I have written a c code which can call this tcl api and get the sum of two integers, but again i don't want it to do this way. I want to create a dll file to use this tcl functionality. Please tell me how to create this dll on visual studio 2010. Any help would be definitely appreciated.
Below is my sample tcl program that i am using :
#!/usr/bin/env tclsh8.5
proc add_two_nos { } {
set a 10
set b 20
set c [expr { $a + $b } ]
puts " c is $c ......."
}
And here is the c code which can use this tcl functionality :
#include <tcl.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
Tcl_Interp *interp;
int code;
char *result;
Tcl_FindExecutable(argv[0]);
interp = Tcl_CreateInterp();
code = Tcl_Eval(interp, "source myscript.tcl; add_two_nos");
/* Retrieve the result... */
result = Tcl_GetString(Tcl_GetObjResult(interp));
/* Check for error! If an error, message is result. */
if (code == TCL_ERROR) {
fprintf(stderr, "ERROR in script: %s\n", result);
exit(1);
}
/* Print (normal) result if non-empty; we'll skip handling encodings for now */
if (strlen(result)) {
printf("%s\n", result);
}
/* Clean up */
Tcl_DeleteInterp(interp);
exit(0);
}
I have successfully compiled this code with the below command gcc simple_addition_wrapper_new.c -I/usr/include/tcl8.5/ -ltcl8.5 -o simple_addition_op
The above code is working with the expected output.
Can anybody now help me with the steps to create a loadable dll for this in visual studio 2010. Please help me, it is very urgent for me.