Creating Installation Independent Projects
Last changed: stevebaer-204.177.179.132

.
DeveloperC++
SummaryHow to set up DevStudio and Rhino projects to be independent of user SDK installation choices.

If you do a lot of Rhino development, it can be helpful to have an environment that's set up with this in mind. If you have the SDK installed somewhere non-standard, and/or intend to share projects with other people, proper setup can be even more helpful.

The following steps will show you how to set up a project that will build correctly from anywhere, on anyone's computer, once a one-time setup has been done.

Initial Setup

The objective of this process is to set up the Rhino SDK as if it were any other standard library. That is, you want to add all SDK-related paths to your default search directories, so that the needed files can be referenced by name only, rather than relative or absolute path. Once this is done, a correctly set up project will compile on any system thus set up, no matter where the project files or SDK files are located.

For this stage, you only need to do a few things. Fire up DevStudio, and go to the "Tools" menu and choose "Options", then find and click on the "Directories" tab. Make sure that the "Show directories for" dropdown is set to "Include files", and add the entry "<SDK>\Inc". Then change the dropdown to "Library files", and add "<SDK>\Lib" and "<SDK>\OpenNURBS\Lib". In each case, replace "<SDK>" with the location you installed the SDK to. That's it! If you're setting up an installation for a project that was created using these guidelines, you should now be able to compile the project, and you can stop reading.

"Fixing" Projects

In order to make a project that can be compiled on any system, regardless of installation choices (provided that system is set up as above), there are a few more steps needed. After creating your project with the existing AppWizard, you will have an StdAfx.h that specifies relative paths, and the libraries will be included files in the project. You can immediately remove the two libraries (rhino3.lib, opennurbs_vc60.lib), but if this is the first time doing this, you may want to keep them for the moment as a reference so you know how to spell them later.

Now that you've cleaned out the unneeded project files (or made a note to yourself to do this later), we'll start by editing the project properties. Select "Settings..." from the "Project" menu, and go to the "Link" tab. Make sure you change the build configuration (in the dropdown labeled "Settings for") to "All Configurations". The current entry for "Object/library modules" should be blank. Add the two libraries you deleted earlier, as follows: "rhino3.lib opennurbs_vc60.lib".

(Tip: While you're here, change the configuration back to "Win32 - Debug", go to the "C++" tab, and change the "Debug Info:" dropdown to "Program Database for Edit and Continue". You might also want to pop back over to the "Link" tab and change the output directory so that all your compiled .RHP's wind up in the same place. All my Rhino projects are in a "Rhino" subfolder in a "Projects" folder, which also has a "Bin" folder with subfolders "Debug" and "Release" for compiled .RHP's.)

Finally, you need to fix StdAfx.h. You should have a file that looks something like this:

  ...
  // Rhino SDK Preamble
  #include "path/to/sdk/RhinoSdkStdafxPreamble.h"
  ...
  // Rhino SDK classes
  #include "path/to/sdk/RhinoSdk.h"...

Change it so that it looks like this:

  ...
  // Rhino SDK Preamble
  #include <RhinoSdkStdafxPreamble.h>
  ...
  // Rhino SDK classes#include <RhinoSdk.h>
  ...

And, you're done! Now, if you move the project, or give it to someone that has the SDK installed somewhere other than where you put it, your project should compile without needing to change any file references to reflect the new relative paths.

-- MatthewWoehlke