After trying many and searching web option to compile and load dll I could not able to create dll for tcl. Can you explain me how to do this.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- How to know full paths to DLL's from .csproj f
- thread_local variables initialization
相关文章
- vs2017wpf项目引用dll的路径不正确的问题
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
Ok, here is a simple example. This code compiles and works for Tcl8.5 and VS2008. To start with I created a WIN32 dll project called BasicTclExtn that exported symbols.
And then the .cpp file
You need to #include tcl.h in the stdafx.h.
This example uses the Tcl stubs facility, see the documentation on the Tcl_InitStubs function for more information; when using stubs you need to link to only the tclstub85.lib. To get the code to link properly you need to do the following:
USE_TCL_STUBS
symbol, I normally do this in Properties-> C/C++ -> Preprocessor -> Preprocessor Definitions. You may also find that you then need to define the<DLLNAME>_EXPORTS
(BASICTCLEXTN_EXPORTS
in my example) after this, I'm not sure why this happens.All of these .lib, .dll and .h files should be easily found in your Tcl installation. You'll also need to ensure that the related tclstub85.dll and tcl85.dll can be found at run time, making sure the bin directory for Tcl is on the PATH should sort that out. So you should then be able to do the following from Tcl:
This is the simplest form of Tcl exstention, you can add additional calls to
Tcl_CreateObjCommand()
to add more commnds into this extension. Tcl provides some faciities to help with the processing of the command line paramters passed into the command. The example code usedTcl_WrongNumArgs()
but you should also look at theTcl_GetIndexFromObj()
functions.I would also suggest you get a copy of Practical Programming in Tcl and Tk by Brent Welch. You can read some sample chapter here http://www.beedub.com/book/, the chapter on C programming for Tcl from the 3rd edition will help you a lot.