Integrated Development Environment How-To's

The RtMidi distribution is designed to work with GNU compilation tools such as automake, autoconf, configure and Makefiles run from command-line interfaces. There is also support for CMake. Thus, simple programs created with RtMidi can be written and compiled with only a text editor and a command-line interface (such as the Terminal.app program in OS-X or MSYS/MinGW in Windows). That said, you may find it useful to use a Integrated Development Environment (IDE) for programming and compiling. IDEs typically provide editors with color-coding of language keywords that can sometimes immediately identify improper syntax, as well as debugging functionality that is more difficult to manage from a command-line interface.

There are many different IDEs available for different operating systems and programming languages. The learning curves necessary to start working in each vary quite a bit. In this section, I will provide very brief summaries of the steps necessary to get a sample RtMidi program setup and compiled on some of the most common platforms.

The assumption in all of the following examples is that we are trying to compile a program called midiout.cpp, which exists in a directory together with the RtMidi.cpp and RtMidi.h files.

OS-X: Xcode

  1. After opening Xcode, select “create a new Xcode project”.
  2. Then select “Command Line Tool” and “Next”.
  3. Provide a project name (I will assume “mytest”) and specify a location in your file system.
  4. Double-click on project name in the left frame to bring up settings in the middle frame (might already be displayed).
  5. Under the “General” tab, specify any frameworks needed in the “Frameworks and Libraries” section ... RtMidi requires the CoreMidi, CoreAudio and CoreFoundation frameworks.
  6. With the “Show the Project navigator” tab selected in the left frame, right-click on project directory that contains the default “main.cpp” file and choose “Add Files to mytest” (there is a checkbox to copy the files, rather than link to them if that is preferred). Add “midiout.cpp”, “RtMidi.h” and “RtMidi.cpp” to the project in this way.
  7. Remove the “main.cpp” default file from the project by right-clicking on it and selecting “Delete”.
  8. To specify preprocessor definitions, go to “Build Settings” in middle frame, click on “All”, then search for preprocessor. Move the mouse to “Preprocessor Macros” and click on “+” for Debug and Release builds, add desired definitions (RtMidi must be compiled with the __MACOSX_CORE__ preprocessor definition).
  9. To compile, click on the arrow button near the top left (“Build and then run the current scheme”).
  10. To specify runtime arguments, go to “Product” -> “Scheme” -> “Edit Scheme …” menu and add under “Arguments Passed On Launch". You can also control whether to compile “debug” or “release” versions in this way (under the “Info” tab).

OS-X or Windows: Eclipse

The Eclipse IDE is freely available on several operating systems for developing a variety of programming languages. The setup should be similar whether on a Windows or an OS-X computer, though the preprocessor definition and libraries will be different.

To create an Eclipse Project to compile an RtMidi program in OS-X:

  1. When first opening Eclipse for first time, create a Workspace directory.
  2. Choose “New C/C++ project”, then “C++ Managed Build”, then “Next”.
  3. Specify a project name, then choose “Executable: Empty Project” and “MacOSX GCC toolchain”.
  4. Select “File->Import”, then “General->File System”, specify source and destination directories (to copy RtMidi.cpp/h and midiout.cpp).
  5. Then use Command-I or menu item “Project->Properties”, “C++ Build”, “Settings”, “Tool Settings”:
  6. Use the “hammer” icon at the top left to compile the program.
  7. Open a Console window in the bottom frame, cd to the working directory, then either the Debug or Release subdirectory, and run the program.

If doing this on a Windows machine, there are two main differences:

OS-X or Windows: Visual Studio Code

The Visual Studio Code IDE is freely available on several operating systems for developing a variety of programming languages. Again, the setup should be similar whether on a Windows or an OS-X computer, though the preprocessor definition and libraries will be different. The following tutorial may be useful.

To create a VS Code Project to compile an RtMidi program in OS-X:

  1. Create a working directory and copy all desired files into it (RtMidi.h/cpp and midiout.cpp).
  2. Then open Visual Studio Code and use the menu “File -> Add Folder to Workspace” to open that working directory. You should see the project files in the frame on the left.
  3. From the main menu, choose “Terminal -> Configure Default Build Task”. A dropdown will appear listing various predefined build tasks for the compilers that VS Code found on your machine. Choose “C/C++ clang++ build active file” to build the file that is currently displayed (active) in the editor.
  4. Edit and save the created tasks.json file as follows:
  5. Click on the “midiout.cpp” file in the left frame and use Cmd-Shift-B to build.
  6. Select “Terminal -> New Terminal”, then run the program in the command line.

If doing this on a Windows machine, there are two main differences:

McGill ©2003-2020 McGill University. All Rights Reserved.
Maintained by Gary P. Scavone.