An Introduction To Embedded Tk (page 23 of 32)

[Previous Page][Next Page][Table of Contents]

11.2 Compiling The Application Code

Once you get et2c and et.o compiled, the hard work is done. To build your application, simply run each source file through the et2c preprocessor before compiling it, and add the et.o library with the final link. For example, the steps to compile a program from two source files, appmain.c and appaux.c, are the something like following on most systems:

   et2c appmain.c >temp.c
   cc -c temp.c -o appmain.o
   et2c appaux.c >temp.c
   cc -c temp.c -o appaux.o
   cc appmain.o appaux.o et.o -ltk -ltcl -lX11 -lm

If you're using a Makefile, you might want to redefine the default rule for converting C source code into object code to incorporate the et2c preprocessor step. Like this:

    .c.o:
          et2c $<>temp.c
          cc -c -o $@ temp.c
The et2c does not harm files that don't use ET constructs, so this rule will work for every file in your project.

[Next Page][Table of Contents]