NT and Ptolemy

Last Updated -[Tue Jan 26 19:12:30 1999 by cxh]-
This consists of my notes for getting Ptolemy to run under NT. Ptolemy 0.7.1 shipped with instructions for building Ptolemy under NT in $PTOLEMY/doc/html/nt

The most recent version of the instructions can be found at: http://ptolemy.eecs.berkeley.edu/~cxh/ptpub/nt/index.html

The notes below are very confusing, but you might find some of the information useful if you are having problems.

Places to go

  • Ptolemy home page
  • Information Week, 3/11/96
  • Unix-to-nt
  • DataFocus, makers of Nutcracker, a Unix development environment for NT.
  • Cygnus win32 page
  • Softway, makers of a POSIX NT subsystem
  • Consensus, makers of Portage.
  • Korn, David G, AT&T Labs, Usenix '97 paper, Porting UNIX to Windows NT - UWIN download page (commercial)
  • Windows NT Unix Services Add-On Pack (5/14/98)A

  • Table of contents
  • Missing NT Tools that Tycho uses
  • Latest instructions
  • August, 2005
  • Janu, 1999
  • Nov, 1998
  • June, 1998
  • May, 1998
  • April, 1998
  • Feb, 1998
  • Jan, 1998
  • Aug, 1997
  • June, 1997
  • March, 1997
  • Feb, 1997
  • PtinyNT
  • Aug, 1996

  • Missing NT Tools that Tycho uses

  • Tycho Tools page

  • August, 2005

    See $PTOLEMY/docs/html/nt/ptxpinstall.html in the CVS download of Ptolemy Classic.

    January, 1999

  • Certain demos, like sdf/basic/lmsFreqDetect fail with deadlocking. I ran the same demo on a working platform and compared the output with the results from Cygwin:
    < 	connect "Fork.output=21" "output#2" LMSOscDet1 error "*1"
    > 	connect "Fork.output=21" "output#2" LMSOscDet1 error
    < 	connect "Fork.output=21" "output#2" LMSOscDet1 error "*1"
    > 	connect "Fork.output=21" "output#2" LMSOscDet1 error
    The above shows that initalizable delays are not being set up properly. This is probably due to my changes to try to get % to work
  • info-zip 2.2 creates zip files that contain files like contents; and interface;, but both unzip5.40 and Winzip 6.3 extract these files as contents and interface, which leaves off the semicolon.
  • The directory name is invalid.
    Unable to create directory: D:/users/ptolemy/lib/technology/ptolemy/con
    Unable to process D:/users/ptolemy/lib/technology/ptolemy/con/
    The directory name is invalid.
    Unable to create directory: D:/users/ptolemy/lib/technology/ptolemy/con
    Unable to process D:/users/ptolemy/lib/technology/ptolemy/con/physical/
    The directory name is invalid.
    Unable to create directory: D:/users/ptolemy/lib/tech/ptolemy/con
    Unable to process D:/users/ptolemy/lib/tech/ptolemy/con/
    The directory name is invalid.
    Unable to create directory: D:/users/ptolemy/lib/tech/ptolemy/con
    Unable to process D:/users/ptolemy/lib/tech/ptolemy/con/physical/
  • sdf/demo/modem fails
    Bad masters were found in $PTOLEMY/src/domains/sdf/demo/modem:schematic:contents:
      Instance of `$PTOLEMY/lib/colors/ptolemy/%dDelay:schematic:interface'
    bash-2.02$ /users/ptolemy/bin.nt4/masters $PTOLEMY/lib/colors/ptolemy/%dBus
    Running masters on /users/ptolemy/lib/colors/ptolemy/%dBus
    /users/ptolemy/bin.nt4/masters: fatal error detected by masters (code 1):
            Cannot open "/users/ptolemy/lib/colors/ptolemy/%dBus:schematic:contents;
    octOpenFacet: Cannot open /users/ptolemy/lib/colors/ptolemy/4Bus/schematic/conte
    nts;: No such file or directory for writing
    bash-2.02$ /users/ptolemy/bin.nt4/octls $PTOLEMY/lib/colors/ptolemy/%dBus
    can not open the facet: octOpenFacet: Cannot open /users/ptolemy/lib/colors/ptol
    emy/4Bus/schematic/contents;: No such file or directory
  • Running vem under Exceed 6.1 with a 65k colors results in
    bash-2.02$ ./vem
    A Serious X Error has occurred:
       BadValue (integer parameter out of range for operation)
       Request X_QueryColors (minor code 0)
    Type 'y' to continue, 'n' to exit, 'a' to abort:
    The work around is to change the colors to 256.
    #10 0x417701 in vemXError (theDisp=0xa034ba0, theError=0x274f358)
        at ../../../../src/octtools/vem/main/errors.c:132
    #11 0x670b2d04 in _size_of_stack_reserve__ ()
    #12 0x670b1719 in _size_of_stack_reserve__ ()
    #13 0x670a3dc6 in _size_of_stack_reserve__ ()
    #14 0x4340e1 in vuWhite (clr=0x274f48c)
        at ../../../../src/octtools/vem/utility/color.c:57
    #15 0x417296 in vemInitCursors ()
        at ../../../../src/octtools/vem/main/cursors.c:119
    #16 0x4173c5 in vemCursor (curName=0)
        at ../../../../src/octtools/vem/main/cursors.c:168
    #17 0x412e29 in main (argc=1, argv=0xa031918)
        at ../../../../src/octtools/vem/main/vem.c:463
    The offending line is:
    	XQueryColor(xv_disp(), xv_cmap(), &white);
    The XQueryColor man page says:
         BadValue  Some numeric value falls outside the range of
                   values accepted by the request.  Unless a specific
                   range is specified for an argument, the full range
                   defined by the argument's type is accepted.  Any
                   argument defined as a set of alternatives can gen-
                   erate this error.
    http://www.hummingbird.com/exceedusers/Sep1998/0031.html describes the following new features in 6.1
    PseudoColor Emulation in Video Modes with More Than 256 Colors
    PseudoColor emulation in video modes with more than 256 colors has been
    improved. To obtain the best results, the following Xconfig Performance
    Settings are required:
    Maximum Backing Store When Mapped or Always
    Default Backing Store When Mapped
    Minimum Backing Store When Mapped
    http://www.hummingbird.com/exceedusers/Jun1997/0039.html has a discussion

    The fix was to modify vuWhite() in vem/utilty/colors.c, see my post to ptolemy-hackers

  • When running sdf/demo/chaoticNoise, pigi crashes, leaving vem running:
    Ptolemy failed to receive response from Vem!
    RPC Error: application: ../../../../src/octtools/Xpackages/rpc/appVem.c (line 22
    3): RPCReceiveLong(&set, RPCReceiveStream): Interrupted system call
    /users/ptolemy/bin.nt4/pigiRpc: fatal error detected by rpc (code -1):
            RPC Error: application: ../../../../src/octtools/Xpackages/rpc/appVem.c
    (line 223): RPCReceiveLong(&set, RPCReceiveStream)
    Vem RPC: client has failed.
    This error occurs when the event loop has problems. To fix the problem, I added the code below to src/kernel/ptsignals.cc
    #if defined (PTNT)
    void ptSafeSig( int ) {}
    sigset_t signalmask = 0;
    void ptBlockSig( int SigNum ) {
            sigaddset(&signalmask, SigNum);
            sigprocmask(SIG_BLOCK, &signalmask, NULL);
    void ptReleaseSig( int SigNum ) {
        /* remove this signal from the signal mask */
            sigdelset(&signalmask, SigNum);
            sigprocmask(SIG_UNBLOCK, &signalmask, NULL);
    Unfortunately, the above fix breaks any simulations that use TK. What happens is that the simulation starts up and then hangs. The workaround is to do
    cd $PTOLEMY/obj.nt4/kernel
    rm SimControl.o ProfileTimer.o
    make USERFLAGS=-DPT_NO_TIMER install
    cd ../pigiRpc
    make install

    I poked around in the Tcl and Tk sources and itimer is not used anywhere.

    SIGALRM is used in two places

    RestoreSignals() in tclUnixPipe.c calls signal(SIGALRM, SIG_DFL); from a child process after forking, right before an exec() This is probably not the problem

    SIGALRM is used in tclUnixTest.c, but this file is only used for testing.

    It looks to me like the problem could have something to do with the select() call in TkUnixDoOneXEvent(timePtr) from tkUnixEvent.c another possibility is the select() call in TclSleep() in tclUnixEvent.c

  • -Wsynth was being reported as a bogus argument to gcc. The fix was to untar the egcs-1.1.1-g++ tar file and reinstall compiler.

  • Nov, 1998

  • Installed Cygwin b20, copied cygwin1.dll to cygwinb19.dll
  • Installed Itcl3.0.1, Tcl8.0.3, Tk8.0.3 via cvs:
    cvs -d :pserver:cvs@cvs.scriptics.com:/cvsroot checkout itcl3.0.1
    cvs -d :pserver:cvs@cvs.scriptics.com:/cvsroot checkout tcl8.0.3
    cvs -d :pserver:cvs@cvs.scriptics.com:/cvsroot checkout tk8.0.3
  • Installing Tcl:
    #if (defined(__WIN32__) || defined(_WIN32)) && !defined(__CYGWIN32__)
  • tcl8.0.3/unix/Makefile.in:
    Commented out -lc on link line. The problem was that link of tclsh fails with multiple definition of environ messages. Most compilers are smart enough to include the c library in the compile these days.
  • unix/tclUnixFCmd.c While linking tclsh: mkfifo not found
    Added the following to tcl8.0.3/unix/configure.in
    Added the following to tcl8.0.3/unix/tclUnixFCmd.c
            case S_IFIFO:
    #ifdef NO_MKFIFO
    	    // FIXME, we need to add this to the results
                fprintf(stderr, "mkfifo not supported");
                return TCL_ERROR;
    	    if (mkfifo(dst, srcStatBuf.st_mode) < 0) {
    		return TCL_ERROR;
    	    return CopyFileAtts(src, dst, &srcStatBuf);
  • itcl problems with shared libs: Be sure that tcl_shared returns the empty string for NT

  • June, 1998

  • Ptolemy 0.7.1 shipped with Ptolemy under NT instructions

  • May, 1998

  • Typing R hangs pigi
  • The NT Task Manager shows that pigiRpc is consuming all the cpu.
  • ptkRunControl in lib/tcl/ptkControl is what is hanging. ptkClearHighlights in pigilib/ptkTclIfc.c never returns.
  • If the user chooses not to display the start up window, then look-inside fails.

  • April, 1998

    Attempting to build vem under NT with X11R6.

    Installing cygwin32 and X11R6.3

    1. Download and install Cygnus GNU-win32 from ftp://ftp.cygnus.com/pub/gnu-win32/latest.
    2. Download Pre-compiled X11R6.3 Libraries/Clients For GNU Win32 B19 .
    3. Install X11R6.3:
      mkdir /usr
      cd /usr
      tar -zxf b19_X11R6_3.tar.gz
    4. Add c:\usr\X11R6.3\bin to your path by using the System control panel.
    5. Verify that the X installation is working by starting up an X server setting your DISPLAY:
      and then running /usr/X11R6.3/bin/xclock.

    Building Ptolemy

    1. Set up your environment by setting the variables below. In the Start menu, select Settings, then Control Panels, then System, then select the Environment tab
      PTARCH nt4
      PTOLEMY /users/ptolemy
      CC gcc
    2. If you have Samba setup, then start up bash and cd to the tree with something like:
      mkdir /users/ptolemy
      mount -b //UnixHost/ptolemy /users/ptolemy
      cd $PTOLEMY
      (The -b option says that text files are equivalent to binary files)

      Now you have three ways to get to the sources using Samba:

      1. Mount a Ptolemy tree located on Unix machine with the Run Start menu choice. T
      2. cd to the UNC, such as cd //carson/ptdesign
      3. cd to the Cygwin mount point: cd /users/ptolemy

      Note that you can set PTOLEMY to the raw UNC format //UnixHost/ptolemy, but if you do, you will have problems with configuring Itcl. Instead use the mount command as above.

    3. Building Itcl2.2:
    4. Download Itcl2.2 from http://www.tcltk.com
    5. In the System control panel, set the CC environment variable to gcc. If you don't then you will get errors while configuring.
    6.  configure --enable-gcc --disable-load --host=i586-CYGWIN32-NT40
    7. If tclEnv.c fails to compile with messages about environ, then edit tcl7.6/generic/tclPort.h. Change:
       #if defined(__WIN32__) || defined(_WIN32)
       #if (defined(__WIN32__) || defined(_WIN32)) && !defined(__CYGWIN32__)
      The above change also needs to be made to tk4.2/generic/tkPort.h and tk4.2/generic/default.h
    8. tclUnixTime.c fails to compile with messages about timezone.
      My fix was to edit tcl7.6/unix/Makefile and change -DHAVE_TIMEZONE_VAR to -DHAVE_GETTIMEOFDAY. The real fix was to modify configure.in so that we run the timezone code instead of just compiling it.
    9. Messages at link time about multiple definitions of -lc
      Fixed by editing tcl7.6/unix/Makefile and commenting out -lc
    10. unix/tclUnixFCmd.c: mkinfo() does not exist.
          if (/*mkfifo(dst, srcStatBuf.st_mode)*/ -1 < 0) {
    11. Run make, then make install
    12. Building vem:
    13. oct/internal.h - cygwin32: errno is actually a function, so we adjust the sys_msg() macro accordingly
    14. iv/iv.c - Fixes for HUGE
    15. rpc/appRPC.c - cygwin32 does not define SIOCSPGRP
    16. Building Ptolemy: Fixed pragma implementation/interface problems when linking ptcl. It looks like the g++ shipped with Cygwin32 is much more picky about pragma interface.
      The following symbol was not present in miscFuncs.o
      inline Attribute operator | (const Attribute& a, const Attribute& b) {
      The problem was that Attribute.h had:
      #pragma interface
      it needed to be changed to:
      #pragma interface "Attribute.h"
      to better match the
      #pragma implementation "Attribute.h"
      in miscFuncs.cc
    17. Unfortunately, Samba and Cygwin32 have problems with mixed case file names. pigilib contained POct.h, poct.h, PVem.h, pvem.h PTcl.h and ptcl.h. The C preprocessor was going into infinite recursion.
      The fix was to fold the lower case .h files into the .cc files that included them.
    18. Binaries under NT end with .exe, so the make.template files in rman-*, tkman-*, optfir and wfir needed to be modified.
    19. At link time, we were getting an undefined symbol from de/kernel/Resource.cc. The following code in Resource.h was present, but the symbol could not be found.
           ResLLCell( DERCEvent* e, double time, int prio) 
                : event(e), ECT(time), priority(prio) {}
      My fix was to move the body of the method into Resource.cc
    20. Error during linking of pigiRpc.ptiny
      ld.exe: final link failed: Permission denied
      The following command can be used to debug
      make LINKER="g++ -v -Wl,--trace,--verbose" pigiRpc.ptiny
    21. sdf/dfm and SR do not compile
      g++ -Wall -Wsynth -Wno-non-virtual-dtor -g -DPTNT -DPT_NO_TIMER \
      -I../../../../../src/domains/sdf/dfm/stars \
      -I../../../../../src/domains/sdf/kernel -I../../../../../src/kernel \
      -I../../../../../src/domains/sdf/tcltk/stars -I../../../../../src/tysh \
      -I../../../../../src/ptklib -I../../../../../tcltk/itcl/include \
      -I../../../../../tcltk/itk/include -I/usr/X11R6.3/include -c \
      ../../../../../src/domains/sdf/dfm/stars/SDFFileEval.cc \
      In file included from \
                       from ../../../../../tcltk/itcl/include/itcl.h:97,
                       from ../../../../../src/tysh/ptk.h:43,
                       from SDFFileEval.pl:171:
      	`typedef float FLOAT' redeclared as different kind of symbol
      ../../../../../src/kernel/dataType.h:48: previous declaration of
      	`const char * const FLOAT'
      The problem here is that Cygwin32 Windows32/Base.h has the line:
      typedef float FLOAT;
      ptolemy/src/kernel/dataType.h has
      const char * const FLOAT;
      This comes up because we are including itcl.h:
      #if defined(__WIN32__)
      #   define WIN32_LEAN_AND_MEAN
      #   include 
      #   undef WIN32_LEAN_AND_MEAN

    Running Ptolemy

    1. Ported bin/pigiEnv.csh to Bourne Shell, creating bin/pigiEnv.sh. One issue was that xrdb was failing because it could not find cpp. I hacked up some code that does the right thing:
          xrdb="xrdb -cpp `gcc --print-prog-name cpp| sed 's@\\\@/@g`" 
    2. Vem error message upon startup:
      Cannot find technology for cell init.pal:schematic:contents:
       Unexpected internal error in function tapGetFacetIdFromObj:
      Cannot open $PTOLEMY/lib/colors/ptolemy/tap.views
      Either technology "ptolemy" does not exist or viewtype "schematic" is wrong.
      The message comes from vem/patterns/tech.c
      vemMsg(MSG_A, "Error detected in %s:\nCannot find technology for cell %s:%s:%s:\n  %s\n",
      mounting with the -b option helped here.
    3. Messages while starting:
      RPC Error: can not fdopen for write in application
      RPC Error: cannot connect to the server
      This error comes from Xpackages/rpc/appNet.c:
      (void) fprintf(stderr, "RPC Error: can not fdopen for write in application\n");
      I was able to start vem under Unix and then connect to NT and replicate this error, so it must be on the pigiRpc side under NT. After the error errno is set to 9
      #define	EBADF	9	/* Bad file number			*/
      The Microsoft VC++ manual says:
      EBADF Bad file number. There are two possible causes: 1) The specified file handle is not a valid file-handle value or does not refer to an open file. 2) An attempt was made to write to a file or device opened only for read-only access.
      The eventual fix was to upgrade to Cygwinb19.1, which has a fix for fdopen. Below is some info about sockets

      Socket resources

    4. Socket FAQ
    5. alt-winsock-faq
    6. The Windows Socket Network Programming book has a section on porting.
    7. Winsock Programmer's Faq
    8. www.sockets.com
    9. Microsoft winsock info says:
      In UNIX, all handles, including socket handles, are small, non- negative integers, and some applications make assumptions that this will be true. Windows Sockets handles have no restrictions, other than that the value INVALID_SOCKET is not a valid socket. Socket handles may take any value in the range 0 to INVALID_SOCKET-1.
    10. Good review in:
      Subject: Re: Porting sockets app from UNIX to NT From: tannenba@cs.wisc.edu (Todd Tannenbaum) Date: 1997/10/17 Message-ID: <626esq$1k4c$1@news.doit.wisc.edu> Newsgroups: comp.os.ms-windows.programmer.tools.winsock
    11. To start vem under Unix and connect to NT, do the following
      1. Install the rshsvc package from the NT Resource Kit CD. Look in rktools.hlp in the Resource Kit. Note that if you change the .rhosts file, you need to stop and restart the rshsvc.

        Note that rshsvc is insecure as hell, and should not be left on. Apparently when you rsh in you automatically have adminstrator privileges.

      2. Be sure that you can rsh from Unix to NT.
      3. Start up pigi under Unix
      4. In the window containing the icons type
      5. To start up the remote side under NT, you will need a .bat file that in turn calls a hacked up .sh file. \\unixhost\ptolemy\tmp\t.bat contains:
        sh /users/ptolemy/tmp/nt.sh %1 %2 %3 %4 %5 %6 %7 %8 %9
        \\unixhost\\ptolemy\tmp\nt.sh is mounted as /unixhost/ptolemy/tmp/nt.sh. That file looks like
        #! /bin/sh -x
        # usage: pigiRpcShell 
        # Version: @(#)nt-ptolemy.html	1.14	08/24/05
        # Copyright (c) 1990- The Regents of the University of California.
        # All Rights Reserved.
        # This shell is invoked by vem via vem's rpc mechanism.  It is our
        # job to recover our environment from the other side of the link,
        # and exec the appropriate actual rpc client.
        # Notes:
        # 1) This is borne shell so that it is fast.  If you make this
        #    a csh script, use the "-f" option so that the user's .cshrc
        #    doesnt clobber the environment.
        # check if we have an environment-passing file
        # SysV uses LOGNAME instead of USER
        if [ -r $cmdfile ] ; then
            . $cmdfile
        libdir=`dirname $0`
        PTOLEMY=${PTOLEMY-`dirname $libdir`}
        ARCH=${PTARCH-`(/bin/arch || /bin/machine || $PTOLEMY/bin/arch ) 2> /dev/null`}
        if [ -z "$COMMAND" ]; then
        cd $HOME
        env > /tmp/env1.$$
        echo "env2: COMMAND='$COMMAND' numberofargs='$#' dollarstar='$*' tailargs='$TAILARGS'" >/tmp/env2.$$
        $COMMAND $* $TAILARGS >/tmp/env3.$$ 2>&1 
      6. To start up the remote process, move the mouse into the window containing the icons and type:
        "NThost \\\\unixhost\\ptolemy\pt\tmp\t.bat"
        and then type a r for :rpc-any
    12. Vem Message while starting
      RPC Error: server: panic!!!  server closing"
      Comes from a line in vem/rpc/server.c that checks to see if we got a RPC_ABORT


    Rebuilding using samba mounted filesystems.
    1. Under Unix,
      setenv PTARCH nt4

    Feb, 1998

    GNU make-2.76.1 has instructions for building it under '95 or NT, see the README.W32 file.

    There are a number of limitations involving names with white space and samba. Also, /bin/sh needs to be present, which requires either cygwin32 or MKS.

    Another idea is to compile Vem and Octtools under NT with X11

  • egcs
  • X11R6
  • X11 and egcs X11R6 Cygwin b19 patch
  • Open Group
  • Jan, 1998

    We are getting more and more NT boxes into our local cluster so we are still interested in the NT port

    I recently installed egcs-1.0 under Solaris, so I was able to fix a number of bugs that were causing problems with the Cygnus cygwin-32 compiler that we use under NT. (egcs and cygwin-32 are based on a similar set of sources)

    The big stumbling block right now is the lack of a gui. We are working on building something with Tycho, but it is still a ways away. The next Ptolemy release, 0.7.1 due out in the summer will have what ever NT support we have completed. However, I doubt if it will be particularly stable. BTW - We have not yet announced 0.7.1, so please don't discuss it on ptolemy-hackers :-)

    We are dropping support of SunOS4.1.3, and I hope to support NT in its place.

    Aug, 1997

    I was able to compile and run the DE domain under Tcl8.0 under NT4.0 There a number of caveats, but I believe that this is a milestone. I used Cygwin18 to compile Tcl8.0b2 with the changes below.
    1. configure --enable-gcc --disable-load
    2. edit generic/TclPort.h and comment out the _WIN32_ body
    3. generic/tclInt.h: include tclUnixPort.h after tcl.h
    4. generic/tclIOSock.h:
      #define SO_SNDBUF 0x1001
      #define SO_RCVBUF 0x1002
      including mywinsock.h results in lots of duplicate symbols and definitions.
    5. unix/tclUnixSock.c:Tcl_GetHostName():
      	#define NO_UNAME
    6. tclUnixFCmd.c: mkfifo() not found at link time: return TCL_ERROR if that code is called.
    7. Makefile: comment out -lc n LIBS rule
    8. tcl8.0b2/unix/tclUnixChan.c: TclGetDefaultStdChannel(): comment out lseek calls that lseek on stdin, stdout and stderr.
    There are the following caveats:
    1. I don't think that the ptcl process can spawn subprocesses.
    2. This is DE only, SDF will not compile without further modifications, cygwin b18 fails because of some casting issues
    3. While compiling, there are lots of warnings about src/kernel/PortHole.h:221: warning base class `class NamedObjList' has a non-virtual destructor.

    Changes to Ptolemy

    Using Cygwin is a bit of a hack here. I think it would be better to build with Microsoft VC++, but this will require adding rules to convert the Unix makefiles to VC++ makefile.vc files. Porting Ptolemy to Microsoft Visual c++ 5.0b
  • ptcl/ptclAppInit.cc: comment out tcl_rcfilename
  • Decided that PTARCH should be set to nt4.vc for MS VC++ compiles and nt4 for cygwin compiles
  • Created config-nt4.vc.mk.vc
  • In the C/C++ code, we check to see if PT_NT4VC is set.
  • Converted common.mk, config-default.mk and compile.mk to .vc files
  • Created ptolemy/src/compat/nt4
  • Clock.cc: Copied timeval decl from winsock2.h
  • DFPortHole.h contains a far() method, which is a keyword in MS VC++. If we use the /Za option to disable extensions, then we can't include files like winsock2.h. The fix is to add -Dfar=ptfar to the compile options.
  • Fix.cc: Fix has min and max methods, which cause trouble with the min and max macros. By using #undef and then redefining the macros by hand later in the file, we work around this. We can't just reinclude minmax.h, as it checks to see if it already has been included.
  • Fix.cc: strcasecmp() is not present, so we add the following:
    	#ifdef PT_NT4VC
    	#define strcasecmp(a,b) strcmp((a),(b))
  • FloatState.cc: EOF not defined Added #include to compat/nt4/std.h
  • IntervalList.cc: strstream.h not found Under nt4.vc, include strstrea.h instead.
  • Linker.sysdep.h: sys/file.h not found Under nt4.vc, don't include sys/file.h
  • Linker.cc: getpagesize not found
  • ProfileTimer.cc: sys/time.h not found Under nt4.vc, don't include sys/time.h, instead include winsock2.h
  • Scope.cc: Scope.cc(99): error C2248: states: cannot access private member declared in class Block Line 99 is in ~Scope(): StateListIter nextState(states); The fix is to add 'friend class Scope;' to the Galaxy class Galaxy.h
  • SimControl.cc: SIGALRM not defined. It looks like NT does not have SIGARLM.
  • Tokenizer.cc: getpid not found Under nt4.vc, include process.h

  • June, 1997

    In June, 1997, I attempted to port Ptolemy to NT using Cygnus cygwin18beta.

    I was able to compile the kernel, the SDF and DE kernel, all the DE stars and most of the basic SDF stars.

    My previous effort had used cygwin17.1beta as a compiler, this time I used cygwin18beta. cygwin18beta now comes with tcl/tk for use with a graphical gdb interface. Since I was having problems linking with tcl/tk, I thought it would be worth giving this a shot.

    Unfortunately, I'm still having problems here, ld is saying that tcl76.dll is not a recognized file. I think that I need to mess around with creating a libtcl76.a file. I found some instructions that might help.

    However, I'm still having problems linking with tcl. Also, the version of gcc that comes with cygwin18beta is much pickier than the vanilla gcc-2.7.2, so there are lots of warnings.

    List of Changes

  • Modified tycho/kernel/Exec.itcl so that we can jump to errors in the make output
    *** 381,388 ****
      	#config -cursor $oldCursor
              # This might not be an error message, it might just be whatever
    !         # exec returned
    !         addHistory "$errMsg\n"
      	if {$statusVariableName == "abnormal"} {
                  addHistory "<>\n"
    --- 381,393 ----
      	#config -cursor $oldCursor
              # This might not be an error message, it might just be whatever
    !         # exec returned.  We process it one line at a time so we
    ! 	# can create hotlinks to the errors.
    ! 	set historyList [split $errMsg '\n']
    ! 	foreach historyLine $historyList {
    ! 	    addHistory "$historyLine\n"
    ! 	}
      	if {$statusVariableName == "abnormal"} {
                  addHistory "<>\n"
  • Still had problems with Matrix.cc, Particle.cc and TimeVal.cc, see below for fixes.
  • Build ptlang by using byacc and then editing ptlang.c and commenting out the #include <malloc.h> line
  • ptlang fails to install because the binary is actually named ptlang.exe. I installed it by hand
  • I did the following setup from within bash:
    mkdir $PTOLEMY/bin.nt4 $PTOLEMY/lib.nt4
  • DEDelay.cc fails to compile, g++ fails with a corrupt stack. I exited and restarted bash and the problem went away!
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) In cygwin_except_handler
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) Exception trapped!
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) exception C0000005 at 10029
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) exception: ax 241DB63 bx 20
    2B2B cx 241DB54 dx 2F
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) exception: si FFFFFFFF di 2
    1DB54 bp 241DA28 sp 241DA24
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) exception is: STATUS_ACCESS
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) Stack trace:
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) frame 0: sp = 0x241D858, pc
    = 0x1000CEC2
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) frame 1: sp = 0x241D874, pc
    = 0x77F94072
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) frame 2: sp = 0x241D898, pc
    = 0x77F88A53
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) frame 3: sp = 0x241D924, pc
    = 0x77F75E82
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) frame 4: sp = 0x241DA28, pc
    = 0x10016211
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) frame 5: sp = 0x241DC58, pc
    = 0x65642F3A
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) In cygwin_except_handler
    (c:\gnuwin32\b18\H-i386-cygwin32\bin\make.exe 1003) Error while dumping state (
    robably corrupted stack)
    make: *** [DEDelay.o] Error 2
  • sdf/stars/SDFAddCx fails to compile:
    SDFAddCx.pl: In method `void SDFAddCx::go()':
    SDFAddCx.pl:27: call of overloaded `Complex(Particle &)' is ambiguous
    ../../../../src/kernel/ComplexSubset.h:50: candidates are:
    Complex::Complex(double, double)
    Complex::Complex(const Complex &)
    g++: Internal compiler error: program cc1plus got fatal signal 33
    make: *** [SDFAddCx.o] Error 1
  • ptcl fails to link with a message like:
    /gnuwin32/b18/tcl/bin/tcl76.dll: file not recognized: File format not recognized
  • Even a simple tclsh fails to link
    Lbash$ make
    gcc tclAppInit.c -I/Itcl2.2/tcl7.6/generic -o tclsh /gnuwin32/b18/tcl/bin/tcl76.
    /gnuwin32/b18/tcl/bin/tcl76.dll: file not recognized: File format not recognized
    gcc: Internal compiler error: program ld got fatal signal 1
    make: *** [tclsh] Error 1
    I think the fix might be to create a tcl76.a by following the instructions in http://www.cygnus.com/misc/gnu-win32/building-reloc-dlls.txt
  • I tried to build Itcl2.2 with cygwin18beta with:
    configure --build=i586-intel-winnt4 --host=i586-intel-winnt4
    but various .h files were missing.

    March, 1997

    In early March, 1997, I attempted to port Ptolemy to NT using Cygnus cygwin17.1beta, available from Cygnus win32 page at http://www.cygnus.com/misc/gnu-win32. Below are my notes from the port.

    The general idea is to build first a ptcl that contains no domains, and then to add the sdf domain.

    After a few changes, I was able to compile the kernel, the ptcl library and a few of the utilities libraries. However, I was unable to run the ptcl executable, there are problems with dynamic libraries and entry points.

    Some of the changes below will probably appear in 0.7, such as the extension to ptarch so that it will return nt4.

    List of changes

  • Modified ptarch to return nt4 and nt5
  • MAKEARCH uses csh, which is not party of cygwin. There are NT versions of csh available, but in the short term, I built in the src/ tree instead of in a separate obj.nt4 tree.
  • I created a config-nt4.mk file.
  • Compiling Linker.h fails:
    Linker.sysdep.h:332: a.out.h: No such file or directory
    Added #if !defined(PTNT)
  • src/compat/ptolemy/compat.h: don't declare putenv under NT
  • SimControl:
    SimControl.cc:305: aggregate `struct itimerval i' has incomplete type and cannot be initialized.
    Looks like there is no itimer, so I commented out part of SimControl::setPollTimer
  • Matrix.cc
    	In method `ComplexMatrix::ComplexMatrix(int, int, PortHole &)':
    	Matrix.cc:527: call of overloaded `Complex(Particle &)' is ambiguous
    	ComplexSubset.h:50: candidates are: Complex::Complex(double, double)
    	ComplexSubset.h:51:                 Complex::Complex(const Complex &)
    	Matrix.cc: In method `FixMatrix::FixMatrix(int, int, PortHole &)':
    	Matrix.cc:921: call of overloaded `Fix(Particle &)' is ambiguous
    	Fix.h:184: candidates are: Fix::Fix(double)
    	Fix.h:200:                 Fix::Fix(const Fix &)
    Line 527 is:
    	    entry(i) = Complex(ph%(totalDataSize - i - 1);)
    Line 921 is:
    	    data[i] = Fix(ph%(totalDataSize - i - 1));
    Offhand, I'm not totally sure what the right fix would be, so I just added a cast to (const Complex &) and (const Fix &) to the test sources. I did not check this change in to the 0.7 tree.
  • Particle.cc:
    	Particle.cc:264: call of overloaded `Complex(const Particle &)' is ambiguous
    	ComplexSubset.h:50: candidates are: Complex::Complex(double, double)
    	ComplexSubset.h:51:                 Complex::Complex(const Complex &)
    	Particle.cc: In method `int ComplexParticle::operator ==(const class Particle &)':
    	Particle.cc:270: call of overloaded `Complex(const Particle &)' is ambiguous
    	ComplexSubset.h:50: candidates are: Complex::Complex(double, double)
    	ComplexSubset.h:51:                 Complex::Complex(const Complex &)
    	Particle.cc:271: warning: control reaches end of non-void function ComplexParticle::operator ==(const Particle &)'
    	Particle.cc: In method `class Particle & FixParticle::operator=(const class Particle &)':
    	Particle.cc:353: call of overloaded `Fix(const Particle &)' is ambiguous
    	Fix.h:184: candidates are: Fix::Fix(double)
    	Fix.h:200:                 Fix::Fix(const Fix &)
    	Particle.cc: In method `int FixParticle::operator ==(const class
    	    Particle &)':
    	Particle.cc:359: call of overloaded `Fix(const Particle &)' is
    	Fix.h:184: candidates are: Fix::Fix(double)
    	Fix.h:200:                 Fix::Fix(const Fix &)
    Same situation as Matrix.cc, I added some casts, but did not add these changes to the 0.7 tree.
  • ProfileTimer.cc:
    	ProfileTimer.cc: In method `ProfileTimer::ProfileTimer()':
    	ProfileTimer.cc:51: aggregate `struct itimerval year' has
    	incomplete type and cannot be initialized
    	ProfileTimer.cc:59: warning: implicit declaration of function `int
    	ProfileTimer.cc:59: `ITIMER_PROF' undeclared (first use this
    Ifdef'd code out with PT_NO_TIMER
  • TimeVal.cc
    	TimeVal.cc: In method `int TimeVal::operator >(const class TimeVal &) const':
    	TimeVal.cc:124: warning: implicit declaration of function `int timercmp(...)'
    	TimeVal.cc:124: syntax error before `>'
    	TimeVal.cc:125: warning: control reaches end of non-void function
    	`TimeVal::operator >(const TimeVal &) const'
    	TimeVal.cc: In method `int TimeVal::operator <(const class TimeVal &) const':
    	TimeVal.cc:129: syntax error before `<'
    	TimeVal.cc:130: warning: control reaches end of non-void function
    	`TimeVal::operator <(const TimeVal &) const'
    Line 124 looks like:
    	return timercmp(this, &t, >);
    timercmp is defined in /usr/include/sys/time.h, but apparently it is not defined under cygwin.

    I modified the test tree I was using, but did not check this change into the developmenttree.

  • Tokenizer.cc:
    	Tokenizer.cc:251: ANSI C++ forbids comparison between pointer and integer
    Line 251 is:
    	else if (strchr (whitespace, c) == NULL) break;
    Added #include , but that did not help Added declaration: extern "C" char * strchr(const char *, int); This change did not make it into the development tree. I don't

    I modified the test tree I was using, but did not check this change into the development tree.

  • The following files in ptcl should use , not "tcl.h"
    	MathematicaTcl.cc:#include "tcl.h"
    	MatlabTcl.cc:#include "tcl.h"
    	ptclAppInit.cc:#include "tcl.h"
    	ptclAppInit.cc:#include "itcl.h"
  • PTcl.cc fails to compile with:
    	PTcl.cc:271: no `int PTcl::cygwin32_connect(int, char **)' member
    	function declared in class `PTcl'
    	PTcl.cc: In method `int PTcl::cygwin32_connect(int, char **)':
    	PTcl.cc:274: no matching function for call to
    	`InterpGalaxy::cygwin32_connect (char *&, char *&, char *&, char *&, char *&)'
    Added #undefine connect to the line just before PTcl::connect

    Building a shared libptcl fails

    gcc: unrecognized option `-shared'
    See the Cygwin dll page for information about how to generate dlls. In the short term, I decided to just build a static pigi.
  • Need to link with static tcl libs, not shared ones. It seems that cygwin ld.exe will not link with dlls. Also, cygwin ld.exe ignores .lib files, it looks for .a files instead.
  • Problems linking
    g++ -L../../lib.nt4  -Wl,-s  ptclAppInit.o     version.o -lptcl -lexttools \
     -lptmatlab -lptmathematica -lptolemy c:/Itcl2.2/itcl/win/Itcl22.lib  \
    	c:/Itcl2.2/tcl7.6/win/Tcl76i.lib  -lg++  -lm  -o ptcl.ptiny
    c:/Itcl2.2/tcl7.6/win/Tcl76i.lib(Tcl76i.dll)(.idata$2+0x0): multiple definition of `idata$2'
    c:/Itcl2.2/itcl/win/Itcl22.lib(Itcl22.dll)(.idata$2+0x0): first defined here
    c:/Itcl2.2/tcl7.6/win/Tcl76i.lib(Tcl76i.dll)(.idata$2+0x0): multiple definition of `idata$4'
    c:/Itcl2.2/itcl/win/Itcl22.lib(Itcl22.dll)(.idata$2+0x0): first defined here
    c:/Itcl2.2/tcl7.6/win/Tcl76i.lib(Tcl76i.dll)(.idata$2+0x0): multiple definition of `idata$5'
    c:/Itcl2.2/itcl/win/Itcl22.lib(Itcl22.dll)(.idata$2+0x0): first defined here
    (_trampoline.o): In function `mprotect':
    /pizza/mushroom/noer/beta17/src/gcc/libgcc2.c(.text+0x67): undefined reference to `VirtualProtect'
    I created a library called TclItcl.dll by combining the tcl and itcl .obj files. I added the following to tcl7.6/makefile.vc
    ITCLTMPDIR = ..\..\itcl\win
    ITCLOBJS = \
    	$(ITCLTMPDIR)\itcl_bicmds.obj \
    	$(ITCLTMPDIR)\itcl_class.obj \
    	$(ITCLTMPDIR)\itcl_cmds.obj \
    	$(ITCLTMPDIR)\itcl_linkage.obj \
    	$(ITCLTMPDIR)\itcl_methods.obj \
    	$(ITCLTMPDIR)\itcl_objects.obj \
    	$(ITCLTMPDIR)\itcl_obsolete.obj \
    	$(ITCLTMPDIR)\itcl_parse.obj \
    #	$(ITCLTMPDIR)\dllEntryPoint.obj
    $(TMPDIR)\tclitclvc.def: $(DUMPEXTS) $(TCLITCLOBJS)
    	$(DUMPEXTS) -o $@ $(TCLITCLDLL) @<<
    $(TCLITCLDLL): $(TMPDIR)\tclitclvc.def $(TCLITCLOBJS)
    	set LIB=$(TOOLS32)\lib
    	$(link32) $(linkdebug) $(dlllflags) -def:$(TMPDIR)\tclitclvc.def \
    		-out:$@ $(TMPDIR)\tcl.res $(guilibsdll) $(TCLITCLOBJS)
    Creating TclItcl.lib fixes some of the problems. The VirtualProtect problem I solved as follows:

    /cygnus/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2-961023/libgcc.a contains the undefined VirtualProtect:

    libgcc.a:_trampoline.o:0000007c b .bss
    libgcc.a:_trampoline.o:0000007c d .data
    libgcc.a:_trampoline.o:0000007c ? .stab
    libgcc.a:_trampoline.o:00000418 ? .stabstr
    libgcc.a:_trampoline.o:00000000 t .text
    libgcc.a:_trampoline.o:         U _VirtualProtect
    libgcc.a:_trampoline.o:00000000 t ___gnu_compiled_c
    libgcc.a:_trampoline.o:00000000 T _getpagesize
    libgcc.a:_trampoline.o:0000000c T _mprotect
    libgcc.a:_trampoline.o:00000000 t gcc2_compiled.
    The fix was to edit Linker.cc and comment out the getpagesize() call.
  • I have a ptcl.ptiny, but when I start it up I get a message "The procedure entry point could not be located in the dynamic link library TclITcl.dll"

    http://www.cygnus.com/misc/gnu-win32/faq.html says

    Can I mix objects compiled with msvc++ and gcc?

    Yes, this supposedly works. The key seems to be using MS's LINK.EXE to do the linking instead of GNU ld. There may be issues with constructor calls for C++/Obj C.

    The problem here is that tcl/tk is compiled using MS visual c++, and we need to have g++ set things up for our constructors. It could be that there is a bug in how I built the shared library, but it looks ok

  • Feb, 1997

    Late last year, I had a look using the Cygnus tools to compile the kernel, and had just too many problems. A later release of the Cygnus tools could help here. Also, at Usenix '97 a paper was presented for a package that could help the port.

    I also attempted to use MS VC++, and had lots of problems:

  • The Ptolemy Kernel C++ files have a .cc extension, VC++ wants some other extension. I could not find a way to override this.
  • The Ptolemy makefiles are not at all compatible with VC++ nmake
  • far is a keyword in vc++, we would need to work around this.
    far.c(1) : error C4226: nonstandard extension used : 'far' is an obsolete keyword
    far.c(1) : error C2059: syntax error : ')'
  • We need a replacement for xgraph that will work under NT. With Itcl2.2, we can use the Tk4.2 photo widget to display gifs and ppm images, so we can do away with xv.

    PtinyNT, a small version of Ptolemy for NT.

    Previously, we've released a version of Ptolemy called Ptiny That consists of only SDF (without image stars) and DE. Ptiny0.5.2 was not shipped with the intentions of allowing the user to write new stars.

    If it does not make the package too much larger, I would like to see the binaries support matlab and mathematica.


    Ptiny should be shipped as a very small tar file that consists of everything necessary to run.

  • ptiny.src.tar.gz - Platform independent Ptiny files
  • ptiny.{sol2,sun4,hppa,nt}.tar.gz - Platform dependent Ptiny files The NT port would not include vem, and would ship tysh.ptiny instead of pigiRpc.ptiny
  • ptiny.itcl.src.tar.gz - Platform independent Itcl files.
  • ptiny.{sol2.sun4.hppa,nt}.itcl.tar.gz - Platform dependent tcl files.
  • We should also ship a binary tar files that consists of all of the necessary tar files for each platform

    Directories to ship

  • tycho
  • src/kernel - We might be able to remove a number of code generation files. Perhaps we should have a src/cgkernel directory?
  • Everything in src/domains/sdf, except
  • dfm,image,matrix,vis
  • targets?
  • We can probably strip out some of the stars and demos.
  • Everything in src/domains/de, except atm. There are probably more stars that can come out.
  • Everything in src/utils, except libgslider,ptvhdlsim,rman,tkman
  • src/pigilib, along with whatever lib files necessary to support vem. Eventually vem will disappear.
  • I'd like to see us not ship lib/tcl. What ever (dis)functionality that is in lib/tcl should be in tycho.
  • lib can be cleaned out.
  • On all platforms except NT, we will ship one pigiRpc binary, and no tysh or ptcl. Under NT, we would ship tysh.ptiny and not ship pigiRpc.ptiny.
  • We need a tk replacement for pxgraph, and xv, since NT does not have X.
  • The following directories in src will not be shipped: compat,contrib,filters,ptcl,ptlang,pxgraph,thread,tst,tysh,vendors,xv
  • Todo

    1. Move the codegeneration kernel files to cgkernel.
    2. Determine exactly what files to ship. A tool could help us here.
    3. NT does not have X, so it would help if we had the following: Replacements for pxgraph and xv
    4. Do we want to use autoconf here? We can use a non-free POSIX toolkit to build NT binaries. Should we use autoconf everywhere? Is it worth the effort to rewrite a bunch of code to use autoconf?
    5. Until tycho can replace vem, we won't have graphics on non-X11 platforms.

    Aug, 1996

    To: Tom Lane cc: ptolemy-hackers@messier.eecs.berkeley.edu Subject: Re: Any thoughts on porting Ptolemy to NT? In-reply-to: Your message of Fri, 02 Aug 1996 11:25:13 -0400. <9162.838999513@sss.pgh.pa.us> Date: Fri, 02 Aug 1996 08:57:31 -0700 We've been kicking this around a little in house. Ptolemy as it stands is very Unix and X centric. Clearly vem would have to run on an X server, and porting vem to any other sort of window system would be torture. Part of the plan with Tycho is to use Tcl/Tk as a interface to multiple platforms. In Ptolemy0.6 under Tycho, one can run Universes, though many Universes use pxgraph, which requires X. Here are some stumbling blocks to a Non-X port of Ptolemy: -Tycho does not have a graphical editor, and we are not giving a date as to when there will be one. -There are lots of Unix-isms built in to Ptolemy, including pathname assumptions. -We need a good grapher that can be used instead of Xgraph. Many of the pieces are already in Ptolemy0.6 with the Tk graph stars, but it would be nice if we could just drop something in place of the Xgraph stars. There is a good Tk grapher in the BLT package. Porting vem and Ptolemy to NT would probably be possible, but I have little NT experience, so I'm not sure about the vagaries of RPC. I'd be interested in supporting an NT port, though we don't have a NT machine right now, so my role would probably only be as an advisor. I too would like to hear about Unix->NT porting problems. I do know some people who were working on Tcl7.3 under NT and they had some really weird stdio problems. As an educational institution, there is some value is training people to use NT. Also, my feeling is that NT will only get bigger market share, and Unix will only get smaller. -Christopher -------- I wonder whether anyone has looked into what it would take to port Ptolemy onto Windows NT? (Try not to gag, please...) We're thinking about developing a Ptolemy-based product that would be sold to non-techie types, and it would be nice to be able to put it on a mass-market sort of platform. Unix is great if you have the necessary sysadmin knowledge, but not everyone does. With NT, at least we could refer installation and configuration problems to someone else's tech support line. I'm just starting to research this question, so pointers to general info about Unix-to-NT porting problems would also be useful. thanks for any help, tom lane --------------------------------------------------------------------------- - Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: ptolemy-hackers-request@ptolemy.eecs.berkeley.edu -------- Back to my NT page