Developing with make and wxWidgets using the Solaris/Linux command prompt


Setting up a compiler for use from the command prompt

Sun Studio 11 (CC) for Solaris; GCC version 3.4 (or later) (g++) for Linux
If your GCC compiler on Linux has not been installed in a standard location, some of your compiled applications may not be able to find libstdc++.so at runtime. In this case, you will need to add this library's directory (usually <gcc-install-dir>/lib) to your LD_LIBRARY_PATH environment variable.
For Solaris wxWidgets users, we recommend that you download the GNOME desktop from http://wwws.sun.com/software/star/gnome/index.html. Please be sure that your wxWidgets installation is built with GTK support.

Initializing ArcGIS Engine

With your machine ready for C++ development, there is only a single step to prepare for ArcGIS Engine development, and that is to source the arcgis/init_engine.sh (or .csh, depending on your shell of choice). If you prefer, that can be done in your shell's RC file (.cshrc or .bashrc, for example). Otherwise, you must source that file once per shell.

Setting up your application

Setting up an ArcGIS Engine C++ wxWidgets application is like setting up an ArcGIS Engine C++ application. There are only a few additional libraries, includes, and flags to add to the makefile. For those of you familiar with ArcGIS Engine C++ programming, you will need to add wxctl and aoctl as libraries to link against (that is, add them with the -l flag, as shown in Step 3 below). In addition, you will need to add the wxWidgets CFLAGS and LDFLAGS, which will be generated by a package management script called pkg-config. If you are not familiar with ArcGIS Engine C++ programming, all the steps you need to take in preparing your application are discussed below.
Open your favorite text editor and begin writing your code. Use a makefile to set the following include directories, library options, and compiler options.
If desired, you can utilize template makefiles provided with the ArcGIS Engine. Makefile.SolarisWx provides a starting point for Solaris wxWidgets applications, and Makefile.LinuxWx will get you started with Linux wxWidgets applications. Refer to the next section for details on these templates.
Below, $(AGSDEVKITHOME) is used to refer to the root directory of your ArcGIS Engine install and should be defined once you have sourced arcgis/engine10.0/init_engine.sh (or .csh). For examples of each of these steps, see the template makefiles: Makefile.SolarisWx and Makefile.LinuxWx.
  1. Use the -I compiler option to add some additional include directories:
    • $(AGSDEVKITHOME)/include
    • (Linux) /usr/X11R6/include (or the correct version for your installation)
  2. Use the -L linker option to specify some additional library directories:
    • $(AGSDEVKITHOME)/bin
    • (Linux) /usr/X11R6/lib (or the correct version for your installation)
  3. Use the -l linker option link against some libraries:
    • arcsdk
    • wxctl
    • aoctl
  4. Use the -D compiler option to define the ESRI_UNIX symbol to direct the compiler to read the UNIX support headers from within ArcSDK.h.
  5. Generate wxWidgets compiler and linker arguments with pkg-config:
    • $(shell wx-config --cflags)
    • $(shell wx-config --libs)

Customizing the templates Makefile.SolarisWx and Makefile.LinuxWx

As a convenience, template makefiles, named Makefile.SolarisWx for Solaris wxWidgets applications and Makefile.LinuxWx for Linux wxWidgets applications, are included with ArcGIS Engine for your use. Makefile.SolarisWx and Makefile.LinuxWx can be found in <install dir>/ArcGIS/developerkit10.0/Samples/ArcObjectsCPP/MakefileTemplates. The following steps highlight the specific areas of those files that must be customized for you to use them in your development process. The modifications shown are based on an application that is written in a single code and a single header file, my_application.cpp and my_application.h, and produces an executable that takes in a single file at runtime. The comment text used here to describe the code of the makefile has been modified from the actual comments within the file to reflect the steps being taken.
  1. Throughout the makefile, update the program name, currently 'wx_sample', to reflect your application name. In this example, the program name is my_application.

         # Set up the program name
         PROGRAM = my_application
         ...
         # Program name updates - source list
         CXXSOURCES = my_application.cpp
         ...
         # Program name updates - objects, dependencies, and compilation commands
         my_application.o: my_application.cpp my_application.h
         $(CXX) $(CXXFLAGS) -c -o my_application.o my_application.cpp
  2. Update the dependencies list for your application. This line was also shown above to illustrate the update of the program name. However, it may also involve adding additional parameters and lists if the application you are writing is broken up into more files.

         # Program name updates - objects, dependencies, and compilation commands 
         my_application.o: my_application.cpp my_application.h
             $(CXX) $(CXXFLAGS) -c -o my_application.o my_application.cpp
With your makefile prepared, you are ready to write your code. Don't forget to start by including ArcSDK.h!

Compiling your application

Once Makefile.SolarisWx or Makefile.LinuxWx is ready to compile your application, you can compile from the command line by typing "make -f Makefile.SolarisWx" or "make -f Makefile.LinuxWx", as appropriate.

Running your application

You can either invoke your application directly or through the makefile. If you choose to invoke it directly, you will need to provide command-line parameters from the command line. To use the makefile to run your ArcGIS Engine application, type "make -f Makefile.SolarisWx run" or "make -f Makefile.LinuxWx run", as appropriate.