Menu

C++/Tk on Windows

Help
2005-12-17
2013-04-15
  • Mateusz Loskot

    Mateusz Loskot - 2005-12-17

    Hi,

    Is it feasible to build C++/Tk with VC++ 7.1?
    I've not tried yet but as I see there aren't much dependencies: some of boost libraries (have it on Windows), tk84 and tcl84 libraries (I have as tcl84.lib and tk84.lib from ActiveState Tcl packge) and pthread (what about this one?).

    Should I expect any more problems?
    Thanks for help in advance.
    Cheers

     
    • Maciej Sobczak

      Maciej Sobczak - 2005-12-21

      There should be no problem, and the library was in fact tested in this environment. As far as I remember, the libs you mention suffice to compile the client programs, you will of course need the Tcl/Tk header files as well.
      No threading library is needed - both Tcl/Tk and C++/Tk use the native threading support on Windows.

      Cheers

       
    • Maciej Sobczak

      Maciej Sobczak - 2005-12-21

      Sorry, correction: C++/Tk does not use threading at all. If there is any dependency to any threading library, it's the Tcl/Tk which introduces it. On Windows, if you can run Tcl/Tk programs with what you get from ActiveState, then nothing else is really needed in terms of run-time support. C++/Tk provides only a syntax interface and uses Boost for this, so threads are not involved. In fact, there are platforms where Tcl/Tk does not use threads and there is no need for the threading support at all.

      Cheers

       
      • Mateusz Loskot

        Mateusz Loskot - 2005-12-21

        Thanks very much. I'm going to try to build it today. I'll give a note about results.
        Cheers

         
    • Mateusz Loskot

      Mateusz Loskot - 2005-12-22

      Yesterday, I managed to build one of C++/Tk example using VC++ 7.1 very easily.

      Just to encourage new C++/Tk users which want to use it on Windows, I wrote a small step-by-step HOWTO. Comments are strongly welcome.

      Here it is:

      == How to use C++/Tk with Visual C++ ==

      === Introduction ===

      In this small HOWTO I will explain how to build and
      use C++/Tk on Windows using Visual C++.
      Note, I use Visual C++ 7.1 from Visual Studio 2003 but
      it should be any problem to use Visual C++ 7.0 or 8.0.

      From C++/Tk website:
      "C++/Tk is an interface to the Tk GUI toolkit,
      known from many scripting languages like Tcl, Python or Perl."

      Why to bother C++/Tk?
      If you need to to write GUI for your application very fast then C++/Tk will help you much.
      It brings you simple and fast development of GUI but using (difficult) C++ language.
      Simply, it's simple GUI in C++.

      === Prerequisites ===

      0. Download and unpack latest C++/Tk package

      http://cpptk.sourceforge.net

      1. Boost library

      As you may read from C++/Tk documentation it depends
      on the Boost (http://www.boost.org/), thus visit its homepage,
      download latest release then build and install it according
      to its documentation.
      During this article I use release 1.33.1 (stable)

      2. Tcl/Tk

      As C++/Tk documentation says Tcl/Tk headers and libraries are required.
      Tcl/Tk works on a wide variety of platforms, on Windows too.
      You may also build Tcl/Tk yourself, but I decided to use well-working
      and ready to use ActiveState's ActiveTcl package.
      You may find it here http://www.activestate.com
      For Windows, ActiveTcl is distributed as an executable installer.

      === Building C++/Tk example with Visual C++ ===

      1. Create new Win32 Console Project.

      In Application Settings panel select Console as Application Type
      In Additional options section select Empty project, because
      during this article we will use examples comming with C++/Tk.

      2. Edit project settings

      Open Project Properties dialog.
      In the C/C++ section add to "Additional Include Directories" path to:

      - Tcl/Tk include directory (e.g. C:\Tcl\include)
      - <PATH_TO_UNPACKED_CPPTK> where you have cpptk.h and cpptk.cc files
      - <PATH_TO_UNPACKED_CPPTK>\base where live cpptkbase.h and cpptkbase.cc files

      Now, in the still open Project Properties dialog, go to the Linker section.
      In subsection General, edit "Additional Library Directories" box and add
      path to where you have Tcl/Tk libraries installed (e.g. C:\Tcl\lib).
      Move to Input subsection of Linker and add to Additional Dependencies box
      two libraries: tclXX.lib and tkXX.lib (substitute XX with version number of
      Tcl/Tk you have installed e.g. tcl84.lib and tk84.lib in my case).

      3. Add source files to the project

      Now you can add sources of C++/Tk and source file of example application.
      In this example I suggest to use example0.cc file - simple Hello world!
      test comming with C++/Tk.

      - Add to project C++/Tk files: cpptk.h/cpptk.cc and cpptkbase.h/cpptkbase.cc
      - Add example0.cc file

      Now, you can Build your project. If there are no compilation/linker errors
      you can run example0 test and should see console window + small Tk window
      with one button "Say hello!".
      Everytime you push the button example0 outputs "Hello C++/Tk!" text to the console.

      Enjoy using C++/Tk on Windows!
      --
      Mateusz Łoskot, mateusz@loskot.net

       
    • Mateusz Loskot

      Mateusz Loskot - 2005-12-22

      I'm testing rest of examples coming with C++/Tk and I can not compile two of them using MS VC++ 7.1.
      Those not compilable are example3 and example6.
      In both cases I'm getting the same error massage  which is hard to decode for me.
      Here is the message:
      ------ Rebuild All started: Project: example3, Configuration: Debug Win32 ------

      Deleting intermediate files and output files for project 'example3', configuration 'Debug|Win32'.
      Compiling...
      example3.cpp
      d:\__projects_mloskot\cpptk\cpptk_examples\cpptk_lib\src\base\cpptkbase.h(577) : fatal error C1001: INTERNAL COMPILER ERROR  (compiler file 'f:\vs70builds\3077\vc\Compiler\Utc\src\P2\main.c', line 148)
      Please choose the Technical Support command on the Visual C++
      Help menu, or open the Technical Support help file for more information

      Build log was saved at "file://d:\__projects_mloskot\cpptk\cpptk_examples\example3\Debug\BuildLog.htm"
      example3 - 1 error(s), 0 warning(s)

      ---------------------- Done ----------------------

      As I revealed, in both examples (3 and 6) problem is with callbacks. VC++ 7.1 compiler does not like
      method doDispatch used in Callback1 and Callback2.

      Is this a problem with my configuration or compiler?

      If you would like to test my projects here they are:
      http://mateusz.loskot.net/chwila/cpptk_examples.zip

      cpptk_lib project depends on
      C:\Tcl\lib\tcl84.lib
      C:\Tcl\lib\tk84.lib
      C:\Tcl\include\tcl.h
      C:\Tcl\include\tk.h

      exampleX projects look for cpptk.lib in <ROOT>\cpptk_examples\cpptk_lib\Debug directory
      and headers in
      cpptk_examples\cpptk_lib\src
      but all exmapleX projects are configured with relative paths.

      Thanks in advance for any help
      Cheers

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.