Make your own free website on Tripod.com

wxWindows Library and CS 2704 Code


Preface

This code is, probably, of interest only to Virginia Tech students taking CS 2704 who prefer to develop their applications in FreeBSD. It is provided with no warrantee, expressed or implied, of fitness for any purpose. WxWindows is covered by the GPL license, which says I have to make the source available. You can't download it from here, but you can write me a letter asking for it. Beware: wxWindows source is around 4MB.

Installation instructions

These instructions are for FreeBSD only. The systems I tested are FreeBSD 2.2.6 and 2.2.7. I did not test it on other versions of FreeBSD.

Installing on your home computer

  1. If you are the fortunate Motif owner, skip to the next step. Otherwise, install Lesstif from the FreeBSD packages collection. I have tested the versions 0.83 and 0.85 of Lesstif.
  2. Fetch the wxWindows package wx-1.68.tgz. Login as root and run pkg_add wx-1.68.tgz. This should install the minimal version of the wxWindows library and documentation. (If you ever want to remove it, run pkg_delete wx-1.68.)
  3. Fetch the cs2704 archive cs2704.tar.gz. This is not a package, do not try to pkg_add it. The archive contains the cs2704/ directory. Unpack it somewhere. I suggest you put it in your home directory.
  4. Edit cs2704/Makefile.generic. CS2704DIR must be the absolute name of the cs2704/ directory.
  5. Get GNU make (gmake) from the FreeBSD packages collection. The default FreeBSD make won't make the sources.
  6. Change to the cs2704/ directory and type make to build the sources. Take a bottle of beer - compilation will take a while. Then run the samples in the bin/ subdirectories to see if they work. You will probably want to type make clean_samples later to clean space.
  7. Voila! Everything should be set up now.

Installing in the lab

Note that you must ask lab administrator before installing any software. Libraries alone take 8MB of space. Libraries and samples take 40MB. An average program takes 2MB. You may want to type quota to see how much space you have.
  1. Fetch the wxWindows archive wx-pack.tar.gz. This archive contains Lesstif-0.85 and wxWindows-1.68 header files, libraries, and documentation. Unpack it in your home directory. The wx/ subdirectory will be created.
  2. Fetch the cs2704 archive cs2704.tar.gz. This archive contains Dr. Kafura's code. Unpack it in your home directory. The cs2704/ subdirectory will be created.
  3. Edit cs2704/Makefile.generic. CS2704DIR must be the absolute name of the cs2704/ directory.
  4. Edit cs2704/make.env. WXDIR must be the absolute name of the wx/ directory.
  5. If you are using sh, ksh, or bash, add the following line to ~/.profile: LD_LIBRARY_PATH=$HOME/wx/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH. If you are using csh, add the following line to ~/.cshrc: setenv LD_LIBRARY_PATH $HOME/wx/lib. This line instructs the dynamic linker to look for shared libraries in the ~/wx/lib directory. Logout and login again in order for this option to take effect.
  6. Change to the cs2704/ directory and type make to build the sources. Relax in the chair, but don't smoke because smoking is prohibited in the lab. Check if the examples work. Then type make clean_samples to clean space. If you're low on space, type make libs to make libraries only.
  7. Congratulate yourself with the victory.

Using the libraries

Using wxWindows is pretty straight-forward. Add $(WXDIR)/include/wx/base and $(WXDIR)/include/wx/x to your include path, add $(WXDIR)/lib to your library search path, and link with libwx_motif, libXm, and other libraries. A good example of these settings is cs2704/make.env. Also, see the wxWindows documentation installed in $(WXDIR)/share/doc/wx. Hint: set DEBUGFLAGS=-g in cs2704/make.env to generate debug information.

Cs2704 code comes in four sets of files corresponding to the textbook chapters. These sets should not be mixed with each other. The src/ subdirectory of each chapter contains the sources that are combined in the library lib/libcs2704ch<n> or lib/libcs2704ch<n>s<m>. The samples/ subdirectory contains the sources for the samples. All binaries are built in bin/. The objects/ subdirectory is for *.o files, the include/ subdirectory is for headers, and the doc/ subdirectory contains the documentation in HTML. I suggest you use usr/ for your projects.

The easiest way to start your project is to start from one of the samples. For example, cd to cs2704/Chapter2, mkdir usr/, and copy Sample1.cpp, Base.cpp, Sample1.inc, and Makefile from samples/ to usr/. Modify these files as appropriate. They are reasonably comented, so modification should be easy enough. If you do not like my source tree policies, do not use my Makefiles.

Makefiles accept the following targets:

  1. all           builds everything in current directory and below.
  2. libs          builds libraries only. This option is available only from the root Makefile.
  3. clean         cleans all objects, libraries, and binaries in current directory and below.
  4. clean_obj     cleans all objects in current directory and below.
  5. clean_samples cleans all samples. This option is available only from the root Makefile.
  6. Other targets are not of general interest.

Troubleshooting

  1. Make sure you are using GNU make (gmake).
  2. If the code doesn't compile, edit cs2704/make.env. All system-specific settings are there.
  3. If some header files are reported missing, try adding -I$(WXDIR)/include and your specific include directories to XINCLUDE in cs2704/make.env.
  4. If you press File-Quit in the Frame window (not in the startup window) the program will likely core dump. The same behavior was observed under BC++/win32. I tend to think this is the bug in Dr. Kafura's code.
  5. Dr. Kafura's code has memory leaks. Keep that in mind when doing dynamic memory allocation. You may want to link with a garbage collector (there is one by Boehm in FreeBSD packages collection), or patch his code, or use raw wxWindows.

Good Luck! You need it... ;-)



- Alex Verstak
averstak@vt.edu
Last updated: Sept 6, 1998