VIDE User's Guide
 
VIDE User Guide Editor Reference VIDE Java Tutorial
Command Reference Tool Reference VIDE C++ Tutorial
VIDE Quick Start Guide

VIDE C/C++ Tutorial


VIDE Overview

The design of VIDE has been somewhat evolutionary, but you should find that it is not that much different than other IDEs you may have used. Because VIDE is a free, open source program based on the V GUI library, it probably lacks some of the visual polish of commercial IDEs. However, VIDE is the result of years of using non-Microsoft C and C++ compilers (and small Java projects), and has very finely tuned functionality. It does almost everything a programmer needs and wants to do while developing software. It is indeed easier to develop programs with VIDE than it is to use a command line interface. And VIDE works equally well on Windows and Linux systems.

Generally, any application you write will consist of various source files (with associated header files for C/C++), and required data files. These files are generally dependent on each other. By defining a VIDE Project for your application, all the file dependencies are automatically handled. The standard tool make is used for C/C++ files, while the JDK Java compiler automatically handles dependencies.

Using VIDE, the normal work cycle goes:

  1. Design your application.
    VIDE currently has no capabilities to help with this stage.
  2. Start VIDE, and create a Project File.
    This will include all source files, compiler options, and other information needed to compile your application.
  3. Build your project.
    This stage compiles your source into object code. Compilation errors are displayed in the status window, and you can simply right-click on the error to go to the offending line in your source code. After making corrections, you repeat this step until all compilation and linking errors are removed.
  4. Run your program.
    You can start your program from within VIDE.
  5. Debug your program.
    VIDE for has integrated support for the gdb debugger for C/C++ on both MS-Windows and Linux. On Linux, you can specify DDD as your preferred debugger in the Options menu. VIDE also supports jdb.
  6. Write documentation for your application.
    VIDE has syntax highlighting for HTML to make that job easier. You can also automatically launch your web browser to view the resulting HTML pages. Really neat.

Using VIDE with GNU gcc/g++  top

The main C/C++ compiler VIDE is designed to work with is the GNU Compiler Collection (gcc), either on a Unix-like (e.g., Linux) system, or on MS-Windows with the GNU GCC compiler. (VIDE will work with either the MinGW version of GCC, or the Cygnus version.)

VIDE uses a standard Makefile to control building your files. Normally, VIDE will automatically generate a Makefile based on the project file. However, you can also use a Makefile you've written manually, or a Makefile supplied with a program. In one case, you use the Project menu to open a VIDE project, in the other you select a Makefile. In either case, when you build the project, all messages will be displayed in the VIDE console.

VIDE assumes you have your gcc/g++ compiler already installed on your system and the PATH correctly set. For Unix/Linux systems, this is a given. If you are using a MS-Windows version (MingGW or Cygnus), then you must follow the instructions provided with their distributions. You might find it helpful to copy the VIDE executables to the /bin directory that has your g++ compiler. VIDE requires GNU make (it is not compatible with some other versions of make), the GNU C/C++ compiler (preferably the latest version of gcc) and associated utilities, and the GNU gdb debugger. You also may want the V utilities vgen and viconed.

Using VIDE with Borland C++ 5.5 top

Beginning with version 1.07, VIDE has added support for the free Borland compiler. This support includes support for running Borland's Turbo Debugger. More complete information about using VIDE with the Borland compiler is found in the VIDE Borland reference guide. It is essential that you read the information in that reference to get a properly working version of VIDE with Borland BCC32.

Functionality of VIDE for BCC32 is based on the non-standard Borland MAKE program. VIDE uses a Borland make Makefile to build your project. Thus, you must have a Makefile defined. This Makefile can be one created automatically by VIDE itself from your Project file, or one you've written yourself. If you have your own Makefile, then you probably won't need to use a VIDE Project.

VIDE assumes you have your Borland compiler already installed on your system and the PATH correctly set. When working with the Borland compiler, VIDE requires the Borland make.

VIDE Projects top

General procedures

Once you start VIDE, you will see a blank window called the "VIDE Console". This initial window is the message window, and is used to output the results of your make. A typical first step after starting VIDE is to open a VIDE Project or select an existing Makefile.

Once you've opened a project or specified a Makefile, you can build your project with the Build:Make C++ menu command, or click on the Make button on the tool bar. This runs the make utility with the default target (usually "all"). As the make builds your program, VIDE intercepts the error messages from the compiler and shows them in the message window. You can then right-click the error line, and VIDE will open up the file in question and put the cursor on the offending line. Note that VIDE assumes that the Project file is the root or home directory, and that the source files will be found in the same directory, or named with relative paths from the project directory. VIDE also assumes all your files have unique names (i.e., you don't have files in your project with the same name but in different directories - VIDE won't open two files with the same base name). After you correct the problem, rerun make.

You can also make a specific target in your makefile by using the Make menu: Make:Make <target>. VIDE Projects will generate clean, cleanobj, and cleanbin targets automatically. You can also use the Make:Make <target> command to build other targets.

The tools menu allows you to run your program. If you are using a VIDE Project, then Tools:Run project will run the project you just built. If you are using your own Makefile, then Tools:Run project will prompt you for the file to run.

VIDE C/C++ Projects top

When you are first creating a new project (or moving an existing program to VIDE), click on the Project:New C++/C Project menu. After you select a name for your project, a "wizard" dialog will open that will let you begin defining a project. VIDE will automatically fill in the name of the target based on the name you gave the project. You can change this if you wish. The normal names will be like "foo.exe" on Windows, or simply "foo" on Linux or Unix systems. Libraries end with a ".a" or ".dll" extension: "foo.a" on both platforms (or a ".lib" for the Borland compiler).

Next, select the type of project you want to build. A Console Application runs in a shell or console window, and does not use any GUI components. A GUI application uses a graphical interface. On Windows, this will be the standard WIN32 API, while on X systems, you will have a choice of Athena, Motif, or gtk. You can also use the V GUI. You will be given a choice between using the static V library or a dynamically loaded library. If you are using OpenGL or Mesa, check that box.

You can also build a static library. Static libraries are usually easy to build. Both Windows and Linux support dynamic libraries (called DLLs on Windows and shared libraries on Linux). The current version of VIDE (2.00) also knows how to build DLL libraries for the GNU compiler on Windows. At this time, VIDE does not support DLLs for the Borland compiler, or shared libraries for Linux/Unix.

You can also select if you are building a release version or a debug version of your project. These options simply determine some switches to the compiler. VIDE does not support both a release and a debug build within the same session. The easiest work around for this is to first build one version, then use File->Save As to save the alternate Project file version, then edit the project files as needed.

The Windows version also lets you select which compiler you are using - MingGW, Cygnus, or Borland. Setting the "-mno-cygwin" option will build an application under Cygwin without using the Cygwin DLL.

Once the initial project attributes have been selected, VIDE will open the project editor dialog box with various tabbed items. Most of the fields will be filled in according to the values you set in the opening dialog. The main thing you will probably want to do is add source files using the Files tab. You can set defines as needed in the other tabs. Once you have added the files needed and click "Done," VIDE will create a Makefile suitable to compile your project with gcc or Borland BCC32.

Each of the project editor tabs are described in more detail in the following sections. (Most of these screen shots were taken from the project file that builds VIDE itself using the V GUI library.)

Names

This pane lets you set the target name for the executable or library. You can also change the name of the generated Makefile. Usually, you will use g++ as the compiler. The Borland compiler is BCC32. The The target name determines what kind of final target is built. A ".exe" extension on Windows, or no extension on Linux, causes an executable to be built. If the target name ends in ".a" (or ".lib" for Borland), then a static library will be built. A ".dll" extension is used for DLL files. It is important to get these extensions right to generate the correct kind of target.

The Compiler line lets you set the name of the compiler. If you are building a C or C++ project, this will normally be g++, gcc, or BCC32. If you are using another language, you can set the name of the compiler here. You can also change the name of the Linker, although this is normally g++ or gcc.

Compiler Flags line lets you pass switches to the compiler, such as -O for optimize, or whatever. The linker flags are passed to the linker, and usually consist of a set of library references. The new project wizard will usually fill these fields in as needed for console, GUI, and V apps. The HOMEV value is required for programs that use the V library if the V GUI system has not been installed in the same places as other libraries and include files on your system.

The Linker Flags line is used to pass flags to the linker. This line may be blank. Note that in VIDE Version 1, this line was used to specify the libraries to be included in the build. If you open an old VIDE project that specified libraries with "-l" switches on this line, you will receive a warning, and you will have to manually fix the project to use the Libraries options instead.

You may have to change some of the default switches for your specific compiler or operating system. You should only have to do this once for a project. If you will be creating other projects, you can save a template project in a file of your choice, and then use it as a starting point for new projects.

The Borland guide gives some specific details for the Borland version.

Files

This lets you add the names of the source files included in the project. Clicking ADD brings up a file selection dialog. When you select a file, the file is added without any path name. To delete the selected entry, use the Del button. Until V adds multi-line selection (someday soon), you have to add files one at a time.

On Windows, the source file can be a ".rc" resource file as well. If you include a ".rc" file, VIDE will automatically add the dependency to the Makefile, and use the appropriate resource compiler (WINDRES for gcc or BRCC32 for Borland) to compile a ".o" file for gcc or a ".res" file for Borland.

VIDE has basic support for mixed C++ and C projects. If you add a C source file to a C++ project, VIDE will generate a Makefile that uses gcc instead of g++ for those files.

Note: Using relative file paths

As of VIDE 2.0, when you define a VIDE project file, VIDE assumes that all source files are in the same directory as the project file, or that you specify them using paths that are specified relative to the project directory.

When you add a source file using the Add button, you can use the file browser to select any file. VIDE will then add the file with the correct relative path specified. Note that you can add only one file at a time using the Add button. You can use the Add *.cpp or Add *.c buttons to add multiple files at once. If these files are in a directory other than the project directory, you can use the Set Src Dir button to first change to the appropriate directory bofore adding the multiple files. VIDE will convert their paths to the correct relative path name.

Note that VIDE 2.0 no longer uses a Source directory, and will generate a warning message if you open an old VIDE project that had a Source directory other than "." (dot - the current directory).

Note: Multiple source directories

Sometimes you may want to keep files in multiple directories. With GNU make, this is not a problem. Simply use relative paths. Borland Make has some problems, and doesn't seem to handle embedded relative paths. So, you can specify an exact path if you wish. Simply edit the file, give the full path, but put a leading = (equal sign) in front of the file name. When generating the Makefile, VIDE will then copy the file name literally.

Paths

This lets you specify the directory where you want object files to be generated, and the directory where the binary should be written to. It is best to use relative paths for these whenever possible. You can also list paths for include and library directories. These are passed to g++ with the appropriate switches.

Libraries

Most applications use libraries, and require that you specify the names of the libraries when you build the program. This tab is used to specify the libraries you need. (The VIDE new project wizard may fill in some library names automatically.) You may specify just the base name of the libraries, with or without the "lib" part. Since the order the libraries are specified is often critical, you can arrange the order of the libraries by selecting a library and then using the Up and Down buttons.

If a library is not a system library, you will need to add the path of the library in the Paths section.

Defines

It is often helpful to provide compile time defines for C and C++ programs. This tab lets you add compile time defines. The left list shows a a pool of definitions that you might want to use. To have them included at compile time add them to the Active Definitions list using the ">" button between the lists. The pool will stay constant, while the Active side can be a bit more dynamic as you work with your project. Note that you have to supply the full compiler definition switch: -DFOO or -UNOTFOO.

Advanced

The first field of the Advanced pane lets you define a project specific argument for the ctags program. For example, the entry "-c-types=+p * ../includew/v/*.h" does several things. First, it adds extra information about function prototypes. Then it includes the V library headers in the tags file for easy lookup of functions used from the library. Check the ctags documentation for other switches you might want to use.

The second advanced field lets you specify startup switches for the debugger. (Not shown in this screen capture.) For example, when used with gdb, "-nw" is provided by default to start gdb in non-windows mode.

The other advanced panels let you add lines to the Makefile in one of two places. You will have to have a pretty good understanding of Makefile in order to make effective use of these options.

Anything you add to the "User Makefile Options" list will be written to the generated Makefile immediately after the standard definitions. You could use it to define your own symbols, or whatever.

The "User Targets" list lets you add new targets other than the defaults to make. You can use these to define specific values you want to add to your Makefile. The Borland support uses these to define the default runtime libraries.

If you want to build something other than an executable or a library, there is one important feature provided by the user targets list. If the first entry has "#all" in the it, then VIDE will not generate an "all" target (usually the same name as the target name) for the make file. It assumes you are providing the all target here instead.

Note that when you need a leading tab for the makefile, enter a '\t' into the project. It will be automatically converted to a real tab in the final makefile.

Direct Project File Editing

A VIDE .vpj project files is in fact regular text file. It is laid out in clearly labeled sections. While you can add entries to any section using the Project Editor, advanced users may find it easier to edit the V project file directly to add definitions and targets that aren't generated automatically. Using these two mechanisms (defines and targets), you can build complicated makefiles which will be automatically generated from the project file. It is possible to define practically anything you might need to include in a makefile. For example, all the options needed to generate the Windows DLL version of V are included in a VIDE project file.

I'm not going to explain every detail of the project file format here. Any programmer reasonably familiar with makefiles will be able to see some of the potential of the VIDE project file. For example, VIDE uses a set of standard variable names such as "oDir" and "EXOBJS". The standard make targets are defined using symbols, too. It is easy to define entries in the user defined symbol section that use the makefile "+=" operator to modify and add to the standard symbols. You can add very complicated targets to the user target section, especially when you override the "all" target with the "#all" convention. Perhaps the best thing to do is look as a VIDE Project File, and study the VIDE and VGUI project files for examples of some of the things you can do. The main advantage of using a project file is the automatic generation of dependencies and other features that will be eventually included in VIDE.

VIDE Help System top

VIDE now includes a Help menu. Most of the help is supplied in a separate distribution file, and is in HTML format. V Help uses your default Web Browser to show the help files.

I have attempted to collect the most useful documentation I could find for the various GNU C++ tools. If you download and install the Help files, you should have a very complete and useful set of documents for C, C++, and Java programming at your finger tips. See Installing VIDE for more instructions on how to install VIDE help.

If there are other HTML based documents you would like added to the VIDE distribution, please let me know.

Debugging with VIDE top

VIDE supports the standard GNU gdb and Sun jdb debuggers. The VIDE interface to the debuggers makes it far easier to debug your code, but is of minimalist design. The goal is to make using the native debuggers as easy as possible for casual users, while maintaining the full power of the debugger for experienced users. VIDE accomplishes this by showing a command window interface to the debugger. You can enter any native debugger command in this window, and thus have full access to all debugger features.

VIDE makes using the debugger easier by providing a popup dialog with the most often used commands. And most importantly, VIDE will open the source file in an editor window and highlight the current execution line on breakpoints or steps. It is very easy to trace program execution by setting breakpoints, and clicking on the Step over or Step into dialog buttons. VIDE also allows you to inspect variable values by highlighting the variable in the source and right clicking the mouse.

A description of debug dialog commands is provided in the VIDE Command Reference section.

Debugging C/C++ with gdb

To debug C/C++ programs with gdb, you must first compile the program with debugging information. This is accomplished with the -g switch on the compile line. The current version of VIDE does not provide automatic generation of debug or release makefiles. The easiest way to define VIDE projects for both debug and release versions is to use the Project:Save Project as... command. First, define a release version of the project. Then, using that project as a template, change the switches as needed for your debug version, and save the project under a different name.

The full power of gdb is available in the debugger command window. You may enter any standard gdb command after the "(gdb)" prompt. In fact, there really is limited interaction between VIDE and gdb, mostly handling breakpoints. VIDE starts gdb using the "-f" switch, which causes gdb to send a special output sequence after each break, which VIDE then uses to open and display the highlighted break line.

VIDE maintains its own list of breakpoints, which it keeps even if you start and stop the debugger. It is important that you use VIDE commands to set and delete breakpoints. If you enter breakpoints directly into the gdb command window, VIDE won't know about them, and won't highlight them in your source code.

Limitations with gdb

No Warranty top

This program is provided on an "as is" basis, without warranty of any kind. The entire risk as to the quality and performance of the program is borne by you.


V IDE Reference Manual - Copyright © 1999-2003, Bruce E. Wampler
All rights reserved.

Bruce E. Wampler, Ph.D.
E-mail: bruce at objectcentral.com
www.objectcentral.com