Configuring your C++ environment


As an ArcGIS C++ API developer, you can choose any development environment as long as you use a supported compiler, as noted on the System Requirements pages. However, if you want to use an integrated development environment (IDE) on Windows, Visual Studio 2008 (9.0) is recommended. If you don't want to use an IDE, you can write your code in any text editor and compile it from the command line. If you choose this option, it is recommended that you use the Windows nmake utility, the Solaris make utility, or the Linux make utility, accessed from the corresponding command prompt. Your choice of development environment depends entirely on your personal preference and the tools available.
You are also able to mix and match by coding in one development environment and compiling in another. For example, you can write code in Visual Studio but compile and build it via a script utilizing the command-line tools. Keep in mind, however, that Motif code will not compile or run on Windows.

Configuring your environment

The C++ API can be a powerful tool for ArcObjects programming; however, there are some steps to take to get started with it. All of the documents mentioned in this section are in the help system as individual pages and can be found through the index. The goal of this document is to provide a single work flow that takes you through the steps of choosing a development environment, leaving you with a basic understanding of how to use the C++ API.
For general information on Consuming and extending ArcObjects with the different APIs, see the discussion in the ArcObjects: Foundation of ArcGIS section.

Verify your platform is ready for ArcObjects C++ development

Make sure that you are using a supported product and platform for the C++ API by checking the System Requirements pages. In particular, you should verify that your C++ compiler is among those supported.
This section is intended to give you a starting point for learning the API. However, its purpose is not to teach you how to set up a Windows machine for C++ development, and it assumes that you can already compile a simple C++ program on your computer. The following steps provide a quick check to determine if your computer is at this point. You will only need to follow the Windows or Solaris/Linux section, as applicable to the machine you are working on.
On Windows:
  1. Open Visual Studio 2008.
  2. The easiest way to program with the C++ API in Visual Studio 2008 is to use the Win32 Console Application wizard. To access the C/C++ Console Application wizard, click File > New > Project > Visual C++ Projects > Win32 Console Application. Name your application "configtest".
  3. Replace the contents of the existing configtest.cpp file with the following code:
[C++]
          #include <iostream>
int main(int argc, char **argv)
{
  std::cerr << "Hello world" << std::endl;
}
  1. Press Ctrl+F5, and click Yes to build the .exe file. A window should open that says Hello world.
  2. If you had trouble with any of the steps above, your system is not yet configured for C++ programming, and you should refer to your system documentation or system support personnel to get it set up.
On Solaris or Linux:
  1. Open your text editor and paste the following code snippet into it.
[C++]
          #include <iostream>
int main(int argc, char **argv)
{
  std::cerr << "Hello world" << std::endl;
}
  1. Save it as configtest.cpp.
  2. At the command prompt, type one of the following:
  3. Solaris: "CC -o configtest configtest.cpp" (without the quotes)
    Linux: "g++ -o configtest configtest.cpp" (without the quotes)
  4. A new file, configtest, will be created. Run it by typing "./configtest" (again without the quotes).
  5. Hello world will be displayed.
  6. If you had trouble with any of the steps above, your system is not yet configured for C++ programming, and you should refer to your system documentation or system support personnel to get it set up.

Choosing your platform

The first decision you must make is which development platform: Windows, Solaris, or Linux. Your choice should be based on your ArcObjects programming intentions, as well as your experience.
  • Windows: If you are planning to write command-line ArcObjects applications and most of your programming experience is on Windows, you should use Windows as your platform. Your code will still be cross-platform; you will just need to recompile it on Linux and Solaris.

    However, if you plan to write an application with the Motif widget ArcGIS controls, you will not be able to develop on Windows as the Motif widget set is only available on UNIX. To develop with the ArcGIS controls on Windows, you will need to use the GTK or QT widget set, or another API and its controls, such as the Visual C++ COM API and the COM controls.
  • Solaris: If you are planning to write ArcGIS control applications, or if you plan to write command-line ArcObjects applications, and you are most familiar with Solaris, you should use Solaris as your platform. Your command-line code will still be cross-platform: you will just need to recompile it on Linux and Windows.

    On Solaris you will be developing the Sun Studio 11 C++ compiler (Sun C++ 5.8) or later. However, your development steps will depend on whether you are writing a command-line application or a control application. If you would like to write a Solaris control application, you will decide if you are going to write a Motif, Qt, or GTK ArcGIS control application. Each has benefits and disadvantages, as documented in Choosing Between Motif, Qt, and GTK.
  • Linux: If you are planning to write ArcGIS control applications, or if you plan to write command-line ArcObjects applications, and you are most familiar with Linux, you should use Linux as your platform. Your command-line code will still be cross-platform: you will just need to recompile it on Solaris and Windows.

    On Linux you will be developing with the GCC version 3.4 (or later) C++ compiler. However, your development steps will depend on whether you are writing a command-line application or a control application. If you would like to write a Linux control application, you will decide if you are going to write a Motif, Qt, or GTK ArcGIS control application. Each has benefits and disadvantages, as documented in Choosing Between Motif, Qt, and GTK.
On both Solaris and Linux we recommend that you use the GNU make utility (not the make utility in /usr/ccs/bin) as you develop. The provided ArcGIS C++ samples all require that you use GNU make with their provided makefiles.

Set up and learn about using your platform

Now that you have chosen your platform, the next step is to set up and learn about using your particular development environment.
On Windows, your options are:
On Solaris or Linux, your options are:

Install and register the ArcObjects SDK for Cross Platform C++

Now that your platform and development environment are set, if you have not done so already, install the ArcObjects Software Development Kit (SDK) for Cross Platform C++ on that platform. Make sure to register your ArcGIS Engine Developer Kit and ArcGIS Engine! For more information, see Install and register the SDK.
You should now have a computer configured for C++ development and know how to set up, compile, and run ArcObjects C++ code in your development environment of choice. The next step is to become familiar with ArcObjects and the C++ API.
Before beginning with a new API, it can be helpful to have some idea why things might not be working. Some of the common configuration mistakes are covered in the Troubleshooting section.