Previous Next Table of Contents


2. Basic -- Installation and support software problems, various platforms, etc.

This section is divided into three parts, Installation, Development Environment, and Running Swarm.

2.1. Installation.

2.1.1. Should I use a binary or archive installation?

  1. Question: What does "binary" mean?
  2. Answer: We created one version of Swarm that includes compiled versions of the auxiliary packages tcl, tk, tclobjc, and blt. We require the system to supply the GNU compiler (including Objective-C), Gnu make, the xpm package, and various X-Windows development libraries. It can be installed by properly editing the Makefile.conf. There are different versions of the binary package, so be careful to pick the one that matches the system you have.

  3. Question: What does "archive" mean?
  4. Answer: Swarm is supplied with the full source code. If the user has installed tcl, tk, libobjc, and blt in a Unix system, then Swarm can be compiled to use those libraries. This is the "archive" installation method. The libraries are dynamically loaded by the operating system.

  5. Question: Why prefer the archive method?
  6. Answer: The archive method is more difficult because the user has to configure tcl/tk/blt/libobjtcl, etc. However, the archive user has more control over what options are used in the compilation of these auxiliary libraries. Upgrades to these auxiliary libraries can be made by the user. On some systems, the binary install method may be unsuitable, may conflict with existing software, so the archive method is the only alternative. In addition, patches to the Swarm source code can be applied on archive installs, but not the binary installs.

  7. Question: Where do I get all that software?
  8. Answer: You will find the needed packages in the Swarm homepage along with the current release. You will also find it at ftp://ftp.santafe.edu/pub/swarm/required-software/.

2.1.2. Binary Installation Procedure.

2.1.3. Tcl/tk and BLT versions.

  1. Question: Is BLT1.9 good enough? That's what came with my new linux distribution.
  2. Answer: No. Remove that version of blt, get a newer version of BLT from the SFI web site. Versions 2.1 and 2.3 both can be made to work. If you install Swarm 1.0.5 or later, version 2.3 is preferred. For earlier versions of Swarm, there were some problems with version 2.3, but 2.1 worked fine. Version 2.3 is preferred because it has some additional features and it will work without much modification.

  3. Question: My system came with tk version 4.2 and tcl version 7.6. I read somewhere in the Swarm archive that Swarm won't work with them. Do I have to trash them and downgrade?
  4. Answer: Absolutely not! The Swarm binary version is distributed with tk 4.1 and tcl 7.5, and it should run fine on any system. If you do an archive install, Swarm can be made to work with 4.2 and 7.6. You probably should use BLT 2.3, which will compile and work with the 7.6/4.2 combination just fine. You can use BLT 2.1, as well, but there is one fix that must be made to the source code (see next note).

  5. Question: What do I have to fix in blt2.1 to make it work with tcl 7.6 and tk 4.2?
  6. Answer: In the blt source, find file bltBgexec.c. Line 1178 has to be changed from

    numPids = Tcl_CreatePipeline(interp, argc - i, argv + i, &(bgPtr->pidArr),
    to
    numPids = TclCreateCommandChannel(interp, argc - i, argv + i, &(bgPtr->pidArr),

    You can do this by hand with a text editor or you can apply the patch supplied by Glen Ropella, that you can find in the mailing list archive. Be careful- if you use a Microsoft based computer to read and save this patch, it will have the added carriage returns and it will not work when you copy it into the Unix system. You either must view the patch with a native Linux browser or edit out the carriage returns with a program such as NEdit. After you have the patch, put it in your blt2.1/src directory, and type "patch < blt-patch-for-Swarm-with-tcl7.6."

  7. Question: Can I use a blt2.1 or blt2.3 package from a Unix/Linux distributor, such as Redhat?
  8. Answer: Possibly. Those RPMs are user-contributed, so there is no guarantee they will match your system. You may need to get the SRPM file (source version) and use the --rebuild option to compile libraries that match your system. The blt2.1 rpm is it is built on top of the incremental tcl/tk packages that will also have to be downloaded. Some users have reported inexplicable problems building Swarm in that environment. The RPM for blt2.3 may work fine, since that source requires no special patches to work with tcl7.6 and tk4.2.

  9. Question: You mean I should use blt 2.3?
  10. Answer: Yes, there were some compatability issues early-on, but in swarm-1.0.5, those seem to be worked out. blt2.3 seems to work fine with tcl7.6 and tk4.2. No patching required.

  11. Question: My new linux system has tcl/tk 8.0. What about that?
  12. Answer: On my system, Redhat 5.0, tcl/tk 8.0 is woven into the fabric of the system, and there's no feasible way to yank it out to install the older libraries. It is possible to install tcl7.6 and tk4.2 in a separate directory structure and then CAREFULLY configure the blt, tclobjc, and swarm software to use those files. There is a step by step guide mailing-list guide for that.

    Recently (1-24-98), it has come to my attention that there is a new version of blt2.1 that will work with tcl/tk 8.0. The package is called blt8.0unofficial. The version of Swarm that uses blt8.0unofficial is still in the development stage, but by the time you come across this FAQ, it may be that SFI staff have announced its availability for testing/usage. In a nutshell, here is what will be necessary. First, upgrade to tcl/tk version 8.0p2 (patched version 2), then compile/install blt8.0 (it has good instructions included with it), get a new version of tclobjc and swarm from SFI, compile them, and run the test applications that SFI will have available.

2.1.4. Script for Archive Installation.

    Answer: To give you an idea of how the installation proceeds on a system using the Redhat 4.1 distribution of Linux (which already includes GCC, Obj-C, make, tcl 7.6, tk 4.2, xpm, and X11 development packages), here are the steps that worked for several users. (Special thanks to Sven Thommesen.) A similar script was written for Redhat 5.0 and the special problems of configuring Swarm to run on a system with 2 versions of tcl/tk. Check the mailing-list archive. In the following, the symbol # means "type this at the command prompt."

    1. Build libtclobjc: unpack the source into /usr/src/libtclobjc-1.1b6 (Update: now this is simply called tclobjc-1.2.tar.gz)

    # ./configure --prefix=/usr/local  
    (You will be asked for the locations of tcl and tk, which are both in /usr/lib)
    # make
    # make install

    2. Build the blt source: (I'm assuming you have unpacked the blt source into /usr/src/blt2.1 and applied the BLT patch described above.)

    # cd /usr/src/blt2.1
    # ./configure --prefix=/usr/local
    # make
    # make install

    (If there's problems, check in config.BLT that: TCLINCDIR=/usr/include, TCLLIBDIR=/usr/include/../lib, TKINCDIR=/usr/include, TKLIBDIR=/usr/include/../lib, XLIBDIR=/usr/X11R6/lib, XINCDIR=/usr/X11R6/include, PREFIX=/usr/local)

    3. Make a missing link so the dynamic linker will find BLT (may not be necessary on some systems):

    # cd /usr/local/lib
    # ln -s libBLT.so.2.1 libBLT.so.2
    # ln -s libBLT.so.2.1 libBLT.so

    (NOTE: This is necessary because executables look for libBLT.so in the linker path when they run.)

    4. Update the linker database. The crudest (and dangerous) method is to edit the file /etc/ld.so.conf and add "/usr/local/lib" as the first line. Then:

    # ldconfig
    To test the result, do this:
    # ldconfig -p

    This will print out the database of libraries found. Check that the list includes: libtk.so=> libtk4.2.so, libtcl.so =>libtcl7.6.so, libBLT.so.2 => /usr/local/lib/libBLT.so.2.1

      (Updated material here: 2-9-1998) It is SAFER to put /usr/local/lib in your dynamic linker's path by either putting an -rpath statement in the Makefile.conf or by creating an LD_LIBRARY_PATH environment variable. Leave ld.so.conf alone if possible!

      In Makefile.conf (see next step), you can add, after SYSDEPLIBS:

      override EXTRALDFLAGS+=-Wl,-rpath,/usr/local/lib

      This causes the linker to look in /usr/local/lib whenever a Swarm program gets compiled. You can add paths in the same command with additional -rpath commands.

      If you don't add that in the Makefile.conf, you can (in a bash shell), type

      #export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

      This can be put in a profile if you want it to be permanent, of course.

    5. Unpack the Swarm distribution into a directory such as /swarm. That directory is hereafter called $SwarmHome. Edit $SwarmHome/Makefile.conf: (this is an example setup, amend as needed! The INCDIRS are .h files, the LIBDIRS are files whare you find libX11.so, libBLT.so, and so forth.)

    SETUP=NONE
    SYS=GNU/Linux
    LDCONFIG=archive
    OTHERINCDIRS= -I/usr/X11R6/include/X11 -I/usr/include -I/usr/local/include
    OTHERLIBDIRS= -L/usr/X11R6/lib -L/usr/local/lib -L/usr/lib
    SYSDEPLIBS= -ldl //This is VITAL for required dynamic linking in Linux!

    Type "make" and there should be a long sequence of GCC compile results. If error messages say some file.h cannot be found, you need to fix OTHERINCDIRS. If errors say some file.a or file.so cannot be found, then you need to fix OTHERLIBDIRS.

    6. Go into a Swarm application directory, such as heatbugs. (If you don't have them, go get swarmapps.tar.gz on the Web site!) Edit first line of the Makefile to point to the directory where you installed Swarm. Type 'make.' There should be many GCC messages, don't worry. Look for errors like "cannot find libXfoo" or such. Then see what dynamic libraries were linked in by running

    # ldd ./app-name

    If all went well, the list should be headed by: libBLT.so.2 libtk.so libtcl.so. If not, look below.

2.1.5. Problems with BLT installation/configuration.

  1. Question: I'm following the BLT instructions in its "Readme," but nothing happens. Why?
  2. Answer: Lamentably, step 5, "Installing BLT," is missing the commands #make and #make install.

  3. Question: While configuring BLT, it asks for the location of the following file which I cannot find in the whole of the system. * X11/X11.h in directory /usr/X11R6/include. (There is a X.h and X10.h file.)
  4. Answers: 1. This may mean your setup is missing some development libraries for which BLT is looking. One user reported that this problem disappeared after installing the libraries libX11.so and libX11.a and the header files that go with them. BLT generally finds them when they are installed in standard places. These libraries are in the Redhat distribution in a rpm called XFree86-devel-3.2-4.

    2. Other users observe there is a typing mistake in the config.BLT configure script. Instead of telling you what it really wants, X11/Xlib.h, it says it wants X11/X11.h. Even though it says it wants X11.h, which you can't find, just tell it where you find the directory X11 that has Xlib.h. In Redhat Linux, for example, one finds Xlib.h in the directory "/usr/X11R6/include/X11", so the configuration should be told X11/Xlib.h is in "/usr/X11R6/include". The ./configure statement (from a GNU package) has the configuration option --x-includes and --x-libraries that can be used to specify these.

  5. Question: I can't get BLT to compile on my Pentium II system. Why?
  6. Answer: BLT has to be informed that you have a "686" system, which didn't exist when BLT was created. In the blt source directory, go to subdirectory /cf and edit a file config.sub.  Change references [345]86 to [3456]86. Now BLT should make fine.

  7. Question: Does BLT 2.1 work with Japanese Localized Tcl/Tk?
  8. Answer: No.

  9. Question: BLT would not compile. Make quit with an error like the following:
  10. collect2: ld returned 4 exit status
    ld: -ltk4.0: expected libx.so(.major.minor.xxx)

    *** Error code 1
    make: Fatal error: Command failed for target `xyz'

    Answer: The problem is that some linkers don't work with dotted version numbers in the library name. The quick fix is to link libtk.a to libtk4.0, then link with "-ltk". Ensure that no other libtk.a (especially a 3.6 libtk) is in your load path first.

  11. Question: What minimal subset of BLT is necessary for Swarm?
  12. Answer: The necessary parts are: barchart, bitmap, busy, drag&drop, graph, and BLT_ZoomStack.

  13. Question: I've built the latest BLT and compiled heatbugs but get a segmentation fault.
  14. Answer: Could be anything. However, we have seen in the past that forgetting to run make install or forgetting to delete the static library (the .a file) after installing on an ELF system can cause this type of behaviour.

2.1.6. Problems with tclobjc installation/configuration.

  1. Question: I'm following the directions for tclobjc, but the test does not work. "make check" generates a massive pile of errors!
  2. Answer: Try adding "-lobjc -ldl" in the Makefile. That solved the make check problems for my Redhat 5.0 installation. If you look at the Makefile, and there are empty spaces for the tcl and tk include & library directories, go ahead and put in the usual -I/usr... and -L/usr/... stuff. This is important if you have more than one version of tcl/tk in your system and it may find one at compile time and a different one at link time unless you specify these.

    When running Redhat 4.2, with tcl 7.6 and tk 4.2, some of us never did get the make check to work, but Swarm worked anyway. "Note: I was able to run 'make check', after a fashion: firstly, start X first. Next, under doCheckTcl in the Makefile remove the '<' character. If you say 'make doCheckTk' you get a little button you can click. If you say 'make doCheckTcl' you get the Tcl interpreter, and you can type commands to it. I don't believe the check.tcl script gets run, though. If I just say 'make check', then process doCheckTcl used 99%CPU for over 30 min on my PP200 before I killed it ... But at least we no longer get those reams of error messages! --Sven"

  3. Question: Do I need readline support in the tclobjc install?
  4. Answer: No. But at least one user has configured it and Swarm runs fine in a Redhat 4.1 setup. Sven T. says "To get libtclobjc-1.1b6 to include support for the 'readline' library, you have to set environment variables when configuring libtclobjc:
    # make distclean
    # READLINE_INCLUDE_DIR="/usr/include/readline" // RedHat 4.1
    # export READLINE_INCLUDE_DIR # READLINE_LIBRARY_DIR="/usr/lib"
    # export READLINE_LIBRARY_DIR
    # ./configure --prefix=/usr/local --with-readline
    # make
    # make install.
    Then, to get Swarm apps to link properly, add "-lreadline -ltermcap" to the line SYSDEPLIBS in Makefile.conf in $Swarmhome. I did not see any difference in the way my Swarm app ran, however."

  5. Question: The configure script for libtclobjc is looking for a file called libk.a. Where is that?
  6. Answer: You are using the old tclobjc software, which was called libtclobjc. You need to get tclobjc-1.2 or newer.

  7. Question: The linker (and I) cannot find the file
  8. "Tk.h,"
    even though we found "tk.h." Where is it?

    Answer: You most likely do not have libtclobjc installed such that it's in the compiler's library search path. If you don't have tclobjc at all, install it. If you have it already, then ensure that the tclobjc directory is being included in the compile command for gcc. If it isn't, then add it to the OTHERINCLUDES variable in Makefile.conf and recompile Swarm.

2.1.7. Swarm crashes when running test applications (common Tcl problem)

  1. Question: Swarm seemed to compile/install fine, but when I run an application, it crashes and I get a message like this:
  2. could not find a usable init.tcl in the following directories ..... This probably means that Tcl wasn't install properly

    Answer: Assuming you did install Tcl properly, this happens because Swarm can't find libraries that it needs. It does not happen with the archive install method, assuming everything is setup right in Makefile.conf. Binary installation users, however, probably need to create ENVIRONMENT variables.

    If it is the only problem in your setup, you can fix without recompiling Swarm by changing your environment variables. First, find those libraries in your file system, then set the environment variable TCL_LIBRARY equal to the path where you found that file. The same should probably be done for TK and BLT. Depending on the sort of Unix you have, you may need to put these in either .profile or .bash_profile. Explicit instructions for environment variables for binary users are shown in "binary installation procedure" above.

  3. Question: My compiler keeps trying to use libtk.a instead of libtk4.0.a. What's wrong?
  4. Answer: It could be one of two things 1) The dots in the library name or 2) it really is looking for libtk.a. The solution to both problems is to make libtk.a a symbolic link to whatever the latest version of the library happens to be. Archive install users should check ldconfig to find out what their system uses for libtk.a.

2.1.8. GNU Issues (Make and GCC)

  1. Question: I don't have GCC or CC with which to build GCC. What can I do?
  2. Answer: Binary distributions of GCC exist for many platforms. GCC is included in all major Linux distrubutions. Other users should check the GNU sites and the GNU docs for where to find one.

  3. Question: I get
  4. You must apply the patch ./gcc.patch to the gcc source dir
    then recompile and install libobjc.a,
    then rerun this configure script.

    when trying to configure and install libtclobjc.

    Answer: The configure script is telling you that your version of gcc won't compile Obj-C. You don't really have to patch gcc. Simply reinstall gcc to include Obj-C (or ask your sysadmin to do it).

  5. Question: Compiler version mismatch. What does
  6. Module HashTable.m version 6 doesn't match runtime 7
    Compiler (gcc) is out of date
    IOT trap (core dumped)

    mean?

    Answer: This is the warning that the Objective C runtime gives when there's a version skew. Ensure that all the libraries are up-to-date.

  7. Question: I get the following Error from make:
  8. collect2: executing gcc: Permission denied

    Answer: Something is wrong with your gcc installation. collect2 is a special program used to link Objective C and C++ programs (it's invoked by gcc). Apparently it's trying to invoke gcc, but the gcc it's invoking isn't right. Make sure that the collect2, ld, and gcc you're using are all from the same gcc version. You might want to ask your sysadmin.

  9. Question: The linker cannot find the sel_get_any_typed_uid or the sel_get_any_uid functions.
  10. Answer: If you can't find sel_get_any_typed_uid() you are probably using gcc 2.7.0: that function was introduced into the Objective-C runtime only in later versions of gcc. The swarm web page has a link to the latest version of the compiler. Upgrade to 2.7.2 or greater and this should go away.

  11. Question: When trying to compile Swarm on SGI, I get expand: not found. What does that mean?
  12. Answer: This appears to be a problem on older SGI systems. The expand command was being used internally by a script called make-h2x, which is used so far to compile the defobj, collections, and activity libraries. expand is a normal Unix command (so I've always thought) I expected to be on all Unix systems. All it does is expand tabs to spaces; if it's not on your system you can get source from ftp://ftp.gnu.org/pub/gnu/textutils-1.22.tar.gz.

  13. Question: Make bombs with the following error:
  14.    make: Fatal error in reader: ../swarm/Makefile.appl,   
             line 12: Unexpected end of line seen.


    Answer: I think the problem is you are not using GNU make.

2.1.9. _XOpenIM missing.

2.1.10. Problem in Linux libC

2.2. Development Environment Questions.

2.2.1. Do I have to use Emacs?

  1. Questions: I hate Emacs. Do I have to use Emacs?
  2. Answer: No. Files in an application directory can be edited with any text editor and executed from the command line. Linux-using-Emacs-haters might try a program called Xwpe, that supplies a Borland-style development environment, but it is not tailored to Objective-C.

  3. Questions: I want color-coding when I edit.
  4. Answer: For that, you need Emacs, or XEmacs (a competing clone/immitation that newcomers will find easier to use). The .emacs file in your home directory can be edited to make Emacs aware of objective c. The old (deprecated, unsupported) method used a font package called hilit19. Versions 20 of Emacs and XEmacs includes a package called Fontlock. There is built-in support for some color-coding. You have to turn it on, however (see the next question!).

  5. Question: I don't want color so bad I am willing to put up with Emacs. Why else would I need Emacs?
  6. Answer: Emacs is from GNU and integrates tightly with GNU compilers and debuggers.You can do everything with it. A lot of people really like it (once they overcome the initial shock!).

  7. Question: Emacs is hard to use. Any alternatives?
  8. Answer: Yes. Consider the competing program XEmacs. Its authors aim to make it more menu driven, but it also is supposed to comply fully with the Emacs commands and add-on programs. Please note. XEmacs is not the same as the version of Emacs that is X11-aware.

2.2.2. How to get color coding in Emacs (or XEmacs)?

  1. Question: My Emacs doesn't seem to en-color my *.m files.
  2. Answer:

      1. There have been changes on this topic and I've not sorted them out completely. On Emacs version 20 or XEmacs version 20, Fontlock and color-coding for ObjC is built in. The color coding you get is not, in my opinion, very complete or useful.

      One step is to tell the editor which kind of color coding you want. You have to let it know that you want "h" files to use the Obj-C mode of coloring. New versions of Emacs are supposed to know that "m" files are Objective-C files, but I still specify both h and m in the .emacs file in the home directory. Like so:.

      (setq auto-mode-alist
      (append '(("\\.h$" . objc-mode)
      ("\\.m$" . objc-mode)
      auto-mode-alist))

      The use of color is not very good even then, IMHO.

      The next step is to add detail to the .emacs file to control the color editing. There has recently (September, 1997) been discussion of code in the .emacs file to use the newer fontlock package with Emacs. Look here to see the thread begin. For XEmacs users, John Eikenberry posted an excellent piece of Lisp Code that can be added to the .emacs file. Click here to see it!  That code worked fine for me after fixing a few lines that were split apart by the email program used to post it.  Look toward the bottom of the file, you'll see some split words.

  3. Question: I have added *.h to the auto-mode-alist; but, Emacs still fontifies my *.h files as C and not as Obj-C.
  4. Answer: You should edit the .emacs file as described above. Make sure the *.h are appended to the alist and not pre-pended.

2.2.3. Is there a debugger specially designed for Objective-C within Emacs?

2.2.4. Where is the Object Browser?

2.2.5. Got any advice about managing a simulation project?

2.2.6. I'm new to Unix. Got any FAQ for that?

  1. Question: Are you expecting me to be a Unix expert to use Swarm?
  2. Answer: No, but you do have to be willing to learn. If you are new to Unix/Linux, you will no doubt have lots of questions. There will be an initial steep learning curve as you learn commands like these. (The symbol # means "Unix Shell Prompt Here"--that's the place where you type commands. Don't type # at the beginning of commands.)

    # ls --- get a list of files in the current directory (usage tip: "ls -la" gives more information!).
    # cp x y -- copy file x to filename y (usage tip: you can include directory names as part of file names).
    # mv x y--- move file x to file name y (that erases x).
    # rm x --- remove file x (usage tip: type "rm -i x" and watch what happens!).
    # cd dirname ---change to directory "dirname" (cd .. moves you "back one level" in the file system).
    # mkdir dirname --- create a directory called dirname (by default, it is a subdirectory of the current directory).

    After the basics like that, you'll come across more interesting problems and this FAQ is supposed to help you address them.

    Warning about brands and shells. There are several versions of the Unix operating system. You can use Linux, DEC UNIX, HP, etc. There are some subtle differences, especially where free software from GNU is concerned. GNU stuff (like "make" or "gzip") is available as standard on some systems, not others. Also, the shell that is in use--Bourne Shell, Korn Shell, bash, C-shell, etc.--will affect some commands, particularly in the creation of environment variables in the user's setup. So, you have to be self-aware enough to find out what version of UNIX you have and what shell you are using.

  3. Question: I want to know more about those commands. What do I do?
  4. Answer: Try typing

    # man commandname (for example, type "man ls" to see about file lists).

    If the built-in manual system called "man" has an entry for "commandname," you can read it. Some man pages are helpful, many are hopelessly abstract and discouraging to a new comer. There are many manuals you can buy for Unix beginners.

    Also, there is the GNU info program. GNU folks have tried to convince everyone that man pages are bad and that the info format is good (that's why so many man pages say "this is old, use the GNU info page to get the real information). The command "info" will bring up the GNU information pages. If you have Emacs or XEmacs installed, you have easy access to info.

  5. Question: I'm trying to compile a program and the compiler can't find a file. What do I do? Where is that file?
  6. Answer: The compiler probably has to be told in which directory it will find that file. How you specify the location may depend on the program you are compiling. It may be set in an environment variable, a makefile, or a gcc command option.

    Now, how do you find out where the file is on your system? If you have that file in your file system, commands like "find" and "whereis" and "locate" can be used to find out where they are.

    1) The find command

    Example (Rick Riolo): Type this (don't type #. Remember, that's the shell prompt!):

    The above command looks at all the directories on the system below / (root dir), but you could also look in specified subtrees, eg find /usr -name "libX11.a" -print. (Editor's Note: On my system, the -print option is not necessary. It is assumed by default. To speed up the search, add the option -xdev before -name. This confines the search to the current file system, meaning that DOS drives that may be mounted are ignored. If one is unsure of a file's full name, add asterixes around the part that you are searching for, such as "*name*". This is regular expression syntax. The "cannot open" messages are not errors. They are a result from some directories refusing to allow themselves to be inspected because the user does not have permission to open them. )

    To find the all versions of X11 library files, such as libX11.a, one can use regular expression syntax, as in:

    (Of course, the response on your system will depend on what file you have! :) )

    2) The whereis command (Ginger Booth):

    3) The locate command (Jan Kreft):

    I use locate instead of find because I don't have to remember any syntax and locate is much faster so you don't waste time if you made a typo and have to repeat the search.

    locate .gif will print all the gif pictures you have on your disk in an instant. Very nice.

    To be able to use locate, cron.daily (called by the cron daemon) must be configured to update the locatedb database once per day. You must have sys adm rights to do this. The details may be rather system specific.

  7. Question: I need to find a few lines in a massive pile of output that runs up the screen. How?
  8. Answer: The first option is to pipe the results into less or more by adding |less (or |more) on the end of your command. (less is the gnu version of more, so some systems have less and more, but HP or DEC systems might have only more). This will make sure it prints one screen at a time. The more sophisticated and easy answer is to pipe the results to the grep program, which will then pluck out all lines that have a certain word.

  9. Question: My simulation dumps a lot of labels and data into several files. How can I extract the data I want to import into a spreadsheet/plotting package?
  10. Answer (Jan Kreft): Use filters such as grep, cut, paste, uniq, join

  11. Question: My fingers ache from typing long commands and I can't remember all that crap. What can I do about it?
  12. Answer: Use alias. Alias lines can be added to the Unix startup files (.bashrc, .cshrc, or .profile, depending). If you find yourself typing a command all the time, create an alias so that you can type just a few letters and the machine thinks you typed the whole long command.

    Example (Rick Riolo): I find alias very useful for making shortcuts for stuff I do all the time.

    The first is to find out whether some program is running (eg to find out what the process id is so I can kill it!):

    The second is to find out exactly what command I entered a while ago (without have to scroll or arrow-key back...this depends on using a shell like tcsh which has a history command:)

    The number on the left is the command number in the history list, next is the time of execution, and then the command.

  13. Question: I've got two files that I need to compare. What to do?
  14. Answer: Consider the "diff" command. It will compare files, and also can execute patches (see the manual...)!

    Example: (Ginger Booth) Compare (few) source code changes between versions.

    An alias command can be added to the .cshrc file like this:

    so the command "cmf" activates "diff" with all those options. Please consult "man diff" for your options. If your shell is different, a slightly different format for the alias command may be needed. Consult documentation for your shell.

    For example, to compare two files, source/Diffuse.h and fromjanwith/Diffuse.h, you type

    It's hard to get really legible output out of this, but the above says I changed (!) an import to an include (lines 2-4 shown for context), and added (+) two routines (lines 64 and 104 in the 2nd file.)

  15. Question: How can I quickly find out how many lines of code I have?
  16. Answer: Use wc -l.

    Example: (Ginger Booth) The command wc -l will count lines of code, as a rough progress measure or version compare.

    # wc -l source/*.m
    127 source/Base.m
    416 source/Carnie.m ...
    39 source/main.m
    14394 total

  17. Question: I downloaded a file with the tar.gz extension. How do I use it? (The extension tgz is usually the same thing, but tar.gz has been contracted. A file with extension Z is compressed with the standard unix compress program and the user should use uncompress to unpack it. There's a man page for it.)
  18. Answer 1. This file is a GNU-zipped tarball! The program "tar" crams a bunch of files into one file (with a tar suffix). GNU-zip is a compression program for UNIX (comparable to PKzip for DOS). First, figure out where you want to unpack the archive. Move it in that directory. Then un-gzip, then untar. Type

    This creates directories if they are called for in the tar file, or writes files into existing directories if you have unzipped the files from a directory where the system can find the right subdirectories.

    If you are fond of pipes, you can do this in one shot (notice we show gunzip in placeof gzip -d for variety).

    The switch -c sends the output of the unzipping process to the command after the pipe, where it is picked up because the "stdin" is called for by the dash after xvf.

    Answer 2. Simple one step command available on some Unix systems (not AIX, DEC, or HP if they are "out of the box" versions):

    This works for files with suffix .tgz as well.

    Answer 3.  For safety, before untarring consider getting a listing of what is in there. It could be that the person who created the tarball did a crappy job and they are going to dump files all over your hard disk, so WATCH OUT. If you have already unzipped a file, you can use the tar command to view a list of the contents by typing:

    This gives a file list.

    If your tar allows the z switch, then you can look at the contents of the tarball without unzipping it. This is the command:

      #tar -tvfz filename.tar.gz | less         

    (If you don't have the "less" program, use "more")

  19. Question: Any other interesting tar facts worth knowing?
  20. Answer 1. Tar can create an archive for you. To put all the files and directories under /users/someone/ into a tar archive called bozos.tar, type

      tar cvf bozos.tar /users/someone/*

      The switch "c" creates an archive', "v" gives back a verbose report on the process, and "f" tells tar that a file list is following. The * means that every file and every subdirectory will recursively be put into the tar file. If you only want to get the files with extension jpg, replace * with *.jpg. Caution, do not type this:

      # tar cvf filename.tar *

      That will make the tar program try to put filename.tar into itself! It doesn't cause a crash, just a weird tar file. That's why it is best to put in absolute paths (such as /users/someone/* when you create tar archives.

    Answer 2. Notice that some people put a - sign before the switches in a tar command and others don't. They used to be required on most unix systems, now they aren't, but most commands work either way.  Rather than be consistent, I've left most of the examples provided by others in the style they chose.

    Answer 3. (Rick Riolo) You can extract particular files without dumping them all. If you want a file called Tribble.m that is in a directory called "source" in a tar file, do this:

      tar xvf tarfile.tar source/Tribble.m

    Answer 4. As an example of how tar can be used to ship files to a colleague, consider this example (Ginger Booth). Suppose a directory called backups exists. In backups, we want to create a tarball called prestats.tar. Tar is going to get files from a directory called source (in this case, the files are Base.m and Critter.m).

      # tar -cvf backups/prestats.tar source
      a source/Base.m 8 blocks
      a source/Critter.m 33 blocks
      ...
      # ls backups
      prestats.tar
      ...
      # gzip backups/prestats.tar
      # cd backups
      /users/ginger/Sgecko/gecko/backups
      # ls
      prestats.tar.gz
      ...

    Now, you've got it tarred and gzipped. If you wanted to reverse the process, do this:

      # gunzip prestats.tar.gz
      # tar -xvf prestats.tar
      x source/Base.m, 3674 bytes, 8 tape blocks
      x source/Critter.m, 16419 bytes, 33 tape blocks ...
      #114: ls
      prestats.tar source

  21. Question: I just installed a new shared library and the programs that use it say they can't find it. Unix really stinks!
  22. Answer: That's what I thought too. Then I heard about ldconfig. On my Linux machine, it works like this. The ldconfig program runs every time you start your machine, and it maintains a listing of libraries that are available for programs to use. If you don't restart, chances are the library you installed is not yet known to your system. If you don't want to restart, find out where your system has ldconfig, and execute it. In my Red Hat Linux system, it is in the directory /sbin, so I type

    (Actually, before I do that, I look in the file called /etc/ld.conf to make sure the directory into which I added the library is included in the ldconfig's search path. If it is not in there, I add it.)

    And then to get a listing of the files the libraries the system knows it has, type

    Look it over. On the left are "stub" names of libraries. A library will have a version name like 2.3, where 2 is the "major version" and 3 is the "minor version." In the library, there is a hardcoded "stub" which indicates that this library will respond to a request for a certain library name, usually it cuts off the minor version number. In the listing, on the right are stub names that provide the needed information or there are symbolic links to files that can do it. If a system is looking for Motif library version 1.2.4, for example, the ldconfig program will look at the file libXm.so.1.2.4, and it will do two things. First, it sees the "stub" name, the major version name, is libXm.so.1, and it will create a link that points from libXm.so.1 to libXm.so.1.2. That's from the major name to the first minor version name.  Then ldconfig will create a symbolic link in the directory where it finds that library from libXm.so.1.2 to libXm.so.1.2.4. So, any program that calls for the Motif library should ask for the major version libXm.so.1, and then the ldconfig knows it has that, follows the links to libXm.so.1.2.4.

  23. Question: Even after ldconfig, my program can't find a library. What's up?
  24. Answer: Gee, maybe you installed the wrong version of the library! If you are a Linux user, use the ldd program to find out what version your program is looking for. "ldd program-name" causes a list of libraries that the program uses to be printed on the screen. Other Unix systems have similar facilities.

    Example: Netscape for linux includes a version dynamically linked to Motif library 1.2.4. That file is called libXm.so.1.2.4, but when Netscape-dynamic is executed, it asks for libXm.so.1.2, and the linker figures out what it needs. The output from ldd on a Red Hat Linux 4.2 machine looks like this:

2.3. Running Swarm

2.3.1. Window Positions

2.3.2. Destroying Windows.

2.3.3. Color and Swarm.

2.3.4. BLT Graph Problems.

  1. Blank Windows
  2. Question: On the test "graph", I pick on a "config" button and get a lovely blank window. Testing the swarm apps, I also get a lot of charmingly blank windows.

    Answer: This is a BLT/Tk problem. Make sure you're using a version of BLT that works with the current version of Tk.

    It also pays to double check that all versions of blt, tk, tcl you're using, linking, including are correct - I once spent eight hours chasing down a bug that was because of a version mismatch. If you have several versions of tk installed, it can be hard to find the right version.

    (you can build a quick test of BLT by doing "make testGraph" in the support/tkobjc directory. It should make a program that draws a little random time series graph.)

  3. Graph artifact size on HPs
  4. Question: When I run it my hpux displaying on its own screen, some of the graphs data parts are about 0.5cm wide---unreadable, while the part that displays the correspondence between colors (the squares or the lines) and variables are readable.

    Answer: There are two possible contributors to this problem:

    1. GCC having been built with the system assembler instead of the GNU Assembler, and
    2. The lack of a reference to the "rint" function in the libraries.

    It is thought that rebuilding the GNU C compiler (gcc) using the GNU Assembler (gas) instead of the system assembler and replacing "rint(x)" calls with "floor(x + 0.5)" will fix this problem. The real source of the phenomenon is unknown.

  5. Graph Scaling on Stock Market App
  6. Question: I just noticed that the graphs for the stock market simulation don't scale right if you ask to plot all 16 predictors - the graphs show about a centimeter of plots and about 5 meters of predictor names and their associated colors.

    Answer: If you are still having trouble with the graphs, try only plotting 7 or less predictors (choose in the initial parameter window...)

  7. Mousetraps App does nothing
  8. Question: Mousetrap still doesn't do anything when I hit go (except it does become the top cycle burner, so its doing something...). I see the red and black display and two graphs which run (x) from -10 to 10. But the red/black pattern doesn't change and nothing gets drawn on the graphs. (I've waited about 5 minutes or so.) What should I be see happening?

    Answer: What you are probably seeing in the graphical display is the end result when all is done, which is a pattern of red and black that isn't changing. At the end of the run the message "All the balls have landed!" will appear in the window from which you started the app.

  9. Allocation problem after a long run
  10. Question: I get the following run-time error after running for a long period of time:

        (Tcl -eval:) can't allocate data vector while executing<newline>  
        ".wFrame@0x4005e210.wBLTGraph@0x4005dfe0 element append GraphElement<newline>  
        x40062128 { 6090 585 }"<newline>  
        while evaluating: .wFrame@0x4005e210.wBLTGraph@0x4005dfe0 element appe<newline>  
        nd GraphElement@0x40062128 { 6090 585 };<newline>  
        *** event raised for error: OutOfMemory<newline>  
        No more memory available from the system.  Value of sbrk: <newline>  
        *** execution terminating due to error<newline>  
        IOT trap (core dumped)  
          
    Answer: Unresolved. Please send ideas to <swarm-support@santafe.edu>
  11. Tcl Error "invalid command name"
  12. Question: I tried to compile "heatbugs" for a test. It appeared to compile correctly, but when I run the demo, I receive a continuous stream of error messages of the form:

    (Tcl -eval:) invalid command name "blt_bitmap"

    Answer: This means you're using a version of Swarm that does not work with BLT v2.0 or greater. Either get a newer release from the Swarm Web site, or use an earlier version of BLT.

  13. Getting data out of a graph
  14. Question: How hard is it to get my points back out of a BLTGraph? Looking at BLTGraph.m, we've got:

        -addX: (double) x Y: (double) y {<newline>  
        [globalTkInterp eval: "%s element append %s { %g %g }";,<newline>  
                        [ownerGraph getWidgetName], name, x, y];<newline>  
        return self;<newline>  
        }<newline>  
        <newline>  
        -resetData {<newline>  
        [globalTkInterp eval: "%s element configure %s -data { };",<newline>  
                        [ownerGraph getWidgetName], name];<newline>  
        return self;<newline>  
        }  
          
    

    And I want something like

    -getDataI: (int) i X: (double*) x Y: (double*) y;

    Or a pointer to an array of points, if there's an array of points, or whatever.

    Answer: The BLT command for this is

    .g element configure e -data

    i.e., like "resetData" but don't give it the actual data. The return is:

    -data elemData Data {} {0.0 0.0 1.0 3.0 2.0 5.0}

  15. BLTGraph and Tcl/Tk
  16. Question: Does BLTGraph actually communicate with Tcl/Tk through these string lists? Does Swarm communicate with BLTGraph solely through the tkinterp by necessity or policy?

    Answer: Unresolved. Please send ideas to <swarm-support@santafe.edu>

  17. Error on ActiveGraph class application
  18. Question: Where is the problem with the following ActiveGraph object creation?

                 BLTGraph *mflowGraph;<newline>  
                 GraphElement *materialElement;<newline>  
                 ActiveGraph  *mflowGrapher;<newline>  
                 <newline>  
                 StatusM *statusM;<newline>  
                 <newline>  
                 mflowGraph = [BLTGraph create: globalZone];<newline>  
                 [mflowGraph title: "Matrial Flow vs. Time"];<newline>  
                 [mflowGraph axisLabelsX: "time" Y: "Material Flow"];<newline>  
                 [mflowGraph setWidth: 400 Height: 250];<newline>  
                 <newline>  
                 materialElement = [mflowGraph createElement];<newline>  
                 [materialElement setLabel: "Shipment of Products"];<newline>  
                 [materialElement setColor: "red"];<newline>  
                 <newline>  
                 mflowGrapher = [ActiveGraph createBegin: globalZone];<newline>  
                 [mflowGrapher setElement: materialElement];<newline>  
                 [mflowGrapher setDataFeed: statusM]; <newline>  
                 [mflowGrapher setIntAccessor: M(getM)]; <newline>  
                 mflowGrapher = [mflowGrapher createEnd];<newline>  
                 [mflowGraph pack];<newline>  
           

    The StatusM object is defined as:

    @interface StatusM: SwarmObject
    -(int) getM;
    @end

    @implementation StatusM
    -(int) getM {
    return partSINK;
    }
    @end

    Answer: In Objective-C declaring a variable to be of a particular class does not automatically generate an instance of that class in the variable. In other words the variable is initialized to nil.

    BLTGraph *mflowGraph;
    GraphElement *materialElement;
    ActiveGraph *mflowGrapher;

    StatusM *statusM;

    And therefore the statement:

    [mflowGrapher setDataFeed: statusM];

    is setting the DataFeed on mflowGrapher to nil. The grapher therefore complains since it does not have a valid feed object.

    You would therefore need to create the object statusM before giving it as a dataFeed to the grapher by (for example) inserting the statement:

    statusM = [StatusM create: globalZone];

    between the declaration of statusM and its use...

    For the record, local variables are not initialized to any particular value (as opposed to global or static variables) and since statusM is a local variable it would normally not be initialized to nil (and certainly not initialized to any valid object instance).

    In this particular case, though, we were lucky in that the value of statusM was nil which caused the grapher to believe you had never set the feed at all... Otherwise it would have attempted to talk to the feed which would have failed too because as mentioned above, the statusM variable did not yet contain a reference to a valid object (since none was created).

  19. Illegal instruction from Heatbugs
  20. Question: Heatbugs dies. Swarm make'd without a whimper, so did the other apps (mousetrap and market), and they executed fine. But heatbugs crashed with "Illegal instruction (core dumped)". Gdb: no backtrace. So I tossed in some printfs, and found that heatbugs executes fine, after commenting out each of 3 calls to createProbeDisplayFor: . Why would Heatbugs crash due to createProbeDisplyaFor?

    Answer: Unresolved. Please send ideas to <swarm-support@santafe.edu>

2.3.5. HP problems: srandom, random, and rint.

    Question: Make doesn't work because the linker cannot find srandom, random, or rint on HPUX.

    Answer: HPUX apparently has more than one version of libm.a, one in /lib and one in /lib/pa1.1. The version of libm.a in /lib/pa1.1 is, supposedly, a superset of the one in /lib plus utilities that are non-ANSI. To fix this, modify the Makefile.conf file to add "-L/lib/pa1.1" to the OTHERLIBDIR variable.

    Calls to random and srandom functions should be avoided. We're taking them out of the Swarm kernel; but, some calls may still remain. The OO Random library should be used if possible.

    And rint() can probably be replaced with floor(x+0.5) in most cases. Rint() does exist in HPUX /lib/pa1.1; but, there is a claim that there may be a bug in it.

2.3.6. Ranlib.

    Question: Why would Make fail when RE-compiling a Swarm App without having made any changes to the code?

    Answer: It's possible that one of the library's symbol tables has to be regenerated. To find out which one (if any) is messed up, look for a warning in the make output that looks something like the following:

    ld: rhome/sun32/mlg/swarm/swarm/../libtclobjc-1.1b2/lib/libtclobjc.a: warning: table of contents for archive is out of date; rerun ranlib(1)/

    Then run ranlib on the offending library (libtclobjc.a in this example).

2.3.7. Tcl_ResetResult or Tcl_FreeResult.

  1. Question: I'm getting a "Bus error" or some other run-time error when running an application. Gdb exits the program while in Tcl_ResetResult or Tcl_FreeResult. What's wrong?
  2. Answer: Unresolved. Please send ideas to <swarm-support@santafe.edu>

  3. Question: Make quits with an error like:
  4. make: *** No rule to make target `-ltkobjc', needed by `market'. Stop.

    Answer: This indicates that make didn't find "libtkobjc.a" (or whatever the case may be for your error) and it doesn't know how to create it itself. Either your "libtkobjc.a" was not installed or did not get created properly. In this example, "libtkobjc.a" is a part of Swarm and you can check whether the make was successful by changing to directory

    $SWARMHOME/src/tkobjc  
    

    and type make.

2.3.8. Other Problems with Un*x Libraries.

  1. Question: When trying to make a Swarm App, I get a message like:
    1. Undefined                           first referenced<newline>  
       symbol                             in file<newline>  
      Tcl_GetVar                          /net/echelon/opt8/swarm/swarm/lib/libtkobjc.a(TkExtra.o)<newline>  
      Tk_DoOneEvent                       /net/echelon/opt8/swarm/swarm/lib/libsimtools.a(SimParameters.o)<newline>  
      Blt_Init                            /net/echelon/opt8/swarm/swarm/lib/libtkobjc.a(TkExtra.o)  
      

    Answer: The libraries were probably not included in the link command, and if they were, then the linker search path was probably not amended with the directory in which the given library should be found. For example, the above error was generated with the linker command:

    gcc -L/net/echelon/opt8/swarm/swarm/lib \
    -L/net/echelon/opt8/swarm/tcl7.4/lib \
    -L/net/echelon/opt8/swarm/tk4.0/lib \
    -L/usr/openwin/lib -L/net/echelon/opt8/swarm/blt-1.9/library \
    -L/net/echelon/opt8/swarm/libtclobjc-1.1b2 -L/usr/local/lib -g \
    -o heatbugs Heatbug.o HeatSpace.o main.o \
    -lspace -lsimtools -ltkobjc -lactivity -lrandom -lobjectbase \
    -lcollections -ldefobj -lX11 -lobjc -lm

    The following missing flags probably caused the above error:

    -ltclobjc -lBLT -ltk -ltcl

    The libraries included on the linker command library are customizable in Swarm via the OTHERLIBS variable in Makefile.conf in the

    $SWARMHOME  
    

    directory.

  2. Question: The linker is giving me unresolved references for references that I know reside in one of the libraries being linked in (i.e. I can do an ar t libxyz.a and see them.)
  3. Answer: Check the order in which the libraries are specified in the link command. For example, if the object bob() in libxyz.a is referenced by dave() in libpqr.a and the linker command make generated lists -lxyz -lpqr, such that the libxyz.a is searched first, then the linker may not find bob because it's already searched libxyz.a when it gets to the reference to bob().

    In other words: Order matters. Try rearranging your library references in the link command. For Swarm apps, it's a good idea to preserve the order in the Makefile.conf.

2.3.9. Warning on malloc, calloc, printf, etc.

    Question: I'm getting warnings about undefined functions: printf, malloc, calloc, etc. when I compile. What's wrong?

    Answer: In some of the include files used by GCC, the prototypes for some of the standard functions are placed in a C preprocessor

    #ifdef  
    block relying on the __USE_FIXED_PROTOTYPES__ macro. If you use one of these functions, you can either put 
    #define   
    __USE_FIXED_PROTOTYPES__
    in your source code file, or you can use the -e "EXTRACFLAGS=-D__USE_FIXED_PROTOTYPES__" flag on the make command.

2.3.10. Segmentation Fault in Heatbugs in MessageProbeWidget.m

    Question: I get a segmentation fault when I run heatbugs. When using gdb to debug this, it says that the fault occurred at line 104 of MessageProbeWidget.m. What do I do?

    Answer:  This has been fixed in the swarm source code. Please get a newer version.


Previous Next Table of Contents