GraphApp for Windows

What files are included in the distribution?

Try downloading GraphApp.zip first. It contains the complete source code for the Microsoft Windows version of GraphApp.

The GraphApp.zip file contains the following files:

     GraphApp.zip = COPYLIB.TXT   arith.c      events.c
                    README.TXT    bitmaps.c    fonts.c
                    graphapp.prj  buttons.c    init.c
                    graphapp.dsk  context.c    menus.c
                    example.prj   controls.c   objects.c
                    example.dsk   cursors.c    strings.c
                    pizza.c       dialogs.c    windows.c
                    graphapp.h    drawing.c    xredef.c
                    graphapp.c    drawtext.c   internal.h
  

The project files (graphapp.prj and example.prj) are Borland C++ version 3.11 projects. They won't work on other compilers. The pizza.c file is an example program for use with the example project, to demonstrate how to use the library.

The graphapp.c file is the file you should compile to make the library.

What do I do with the graphapp.h file?

The graphapp.h file can be placed in your compiler's include directory, but it doesn't have to be. Here is how to do it with the Borland C compiler:
     COPY graphapp.h C:\BorlandC\Include
  
Why do this? Because then your C programs can use the line
     #include <graphapp.h>
  
to include the file. When the compiler sees the angle brackets < and > around a file name, it tries to find that file in its include directory.

You don't have to put the file there. You could copy the graphapp.h file into the directory where you are compiling programs, and use the following line in your C programs:

     #include "graphapp.h"
  
When the compiler sees the quotes "" around a file name it looks for it in the current directory, where you are compiling.

What do I do with the graphapp.lib file?

Once you have built the library and produced the graphapp.lib library file, you use the library when compiling programs. Here is how to use it:

  1. Make a new project. You want to create a Windows EXE file.
  2. Ensure the project is using the 'Large Memory Model' or the '32-bit Memory Model'
  3. Add the graphapp.lib file to the project.
  4. Add a .c file to the project. A simple program to use is this:
         #include "graphapp.h"
    
         void main(void)
         {
           gprintf("Hello world.\n");
         }
      
  5. 'Make' the project. Usually there will be an option to 'make' the project in the Project or Run menu. In Borland C use the F9 key.

What does 'make' do? It compiles your .c file and links it to the graphapp.lib library file. This should be all you need to do to get programs running. You can also use the 'run' option which should be in one of the menus, which will 'make' the project then run it.

What are all those other .c files for?

The GraphApp.zip file contains several .c files, and the files internal.h and COPYLIB.TXT.

The .c files are the source code files used to build the library, while the internal.h file is only used inside the library, never by your programs. The COPYLIB.TXT file simply states the terms under which you are using the GraphApp source code (basically you cannot use it for commercial purposes unless you use it in an unmodified form).

The graphapp.c file is the main file you will want to compile. It includes the relevant source code files automatically.

How do I build a version of the library for my compiler?

If using Borland C++ 3.11, the project files I used to make the library are supplied in the zip file, so you should be able to just build it.

Otherwise, here are the instructions for doing it:

  1. Make a new project called GraphApp.prj
  2. Ensure the project is using the 'Large Memory Model' or the '32-bit Memory Model'
  3. Add the graphapp.c file which came in GraphApp.zip to the project
  4. Set the project options to the following:
    1. Make a Windows EXE file (not a DLL!)
    2. Set the Make options so it runs the librarian instead of running the ordinary linker. The librarian makes a LIB instead of an EXE.
  5. Build the project.

If all goes well, you will have produced a new graphapp.lib file for use with your compiler. If all doesn't go well, forget it and use the next method instead.

Nothing works, what do I do?

Don't panic!

There is a way you can get GraphApp programs to work by directly linking your source code to the source code files which come in the GraphApp.zip file. Here's how:

  1. Make a new project.
  2. Ensure the project is using the 'Large Memory Model' or the '32-bit Memory Model'
  3. Add your .c file to the project. An example program might be:
         #include "graphapp.h"
    
         void main(void)
         {
           window w;
           w = newwindow("Testing", rect(20,20,200,200),
                          StandardWindow);
           show(w);
         }
      
  4. Add the graphapp.c file which came in GraphApp.zip to the project. You will need to ensure that both graphapp.h and internal.h are in the same directory as the .c files. Do everything in one directory.
  5. Ensure the project is making a Windows EXE file. The Options menu should tell you this somewhere. New projects will normally create a Windows EXE anyway, so you shouldn't have any problems with this step.
  6. 'Run' the project.

Remember the .c files which come with GraphApp are the source code files for the library. If you modify them you may break the library. Then you'll have to unzip the GraphApp.zip file again.

What compiler can I use?

Any compiler which can produce Windows EXE files. Borland C version 3.0 or higher should work, and Microsoft C should also work. The library works best in the 'Large Memory Model' or the '32-bit Memory Model'

What about TURBO C? Turbo C probably won't work because it is an older compiler which pre-dates Windows.

What if I get this error message...?

Linker Error: Fixup overflow at _TEXT:00B1, target = WINMAIN

This error is probably caused by not using the correct memory model. Use the 'Large Memory Model' or the '32-bit Memory Model' when compiling and linking with GraphApp.

Linker Error: Undefined symbol GETSAVEFILENAME in module DIALOGS

Check to see if you have the file COMMDLG.DLL in your WINDOWS\SYSTEM directory.

If COMMDLG.DLL is missing (which may be the case if you are using Windows 3.0) then you may have to download it and copy it into your WINDOWS\SYSTEM directory.

If compiling the GraphApp library yourself, you may have problems if you are using Borland C 3.0, since this version of the compiler didn't know about the COMMDLG functions. You will need to download the COMMDLG.H header file.

The COMMDLG.H and COMMDLG.DLL files can be downloaded from here: http://www.cs.su.oz.au/~loki/graphapp/download/commdlg.zip

If you still can't get the COMMDLG functions working, you may have to include the COMMDLG.LIB import library in your programs. This file is also included in the above mentioned zip file. This import library lists the functions which your compiler must know about so it can link to the COMMDLG.DLL at run-time.

Linker Error: Undefined symbol GETFILETITLE in module INIT

This problem is caused by the same COMMDLG.DLL problem mentioned above.

Linker Error: Missing function MAIN in module INIT

This means you've probably tried to compile the library into an EXE without having a program with a main function.

You should compile the graphapp.c file into a library, not an EXE. Check the "Librarian options" from the Options menu in your compiler, and read the help file. Find out how to create a library, instead of an EXE file.

If you have created the library, you can only run it by linking it to a program. Try making a project which contains graphapp.lib and pizza.c and then compile into an EXE. Remember to use the same memory model both when making the library, and also when making the EXE. Use 'Large' or '32-bit' as the memory model.

If you can't make a library, just put graphapp.c and pizza.c in one project, and compile that into an EXE.

It doesn't work at all. What do I do?

You have two options: send mail to Loki about your problem, or forget about using the Windows version. Remember there is a version which works on X-Windows, so this may be all you need to get your programs done.

If you mail Loki with a problem, understand that he may not be able to give you any advice unless you say exactly what the problem is. Write down the error messages, and record exactly what you did to produce the error. Include details of which compiler, version and operating system(s) you are using.