Cross platform development with the Eclipse CDT

So, you want to create an application that can un under both Linux and Windows?

This is my experiment trying to do just that… Lets see if the Eclipse CDT is robust to do cross platform development!

Step 1: Install the Eclipse 3.3 SDK if you have not already done so. Make sure to get the CDT components. If you download the java sdk, you can add the CDT packages by adding the following plugin update site:

Step 2: Install the cross platform make system, cmake. it’s eclipse download site is:

Step 3: Create a C++ project in eclipse.

  • Go to “New->C++ Project” Menu (or Go to “New->Hello World C++ Project” Menu if you are making an empty project and want to see some c++ code used by default)
  • Select the MakeFile Project type, choose Other Toolchain and click Next
  • Select the Advanced Settings Button
  • Uncheck the Use Default Build Command
  • Insert the following in the Build Command Text Field: make -C ${project_loc}/Build VERBOSE=1
  • Under the “C/C++ Build” options, select “Settings”.
  • In the Right Side pane select the binary format for your system (Elf for linux).
  • Click on the OK Button.
  • Create a file in the project root named: CMakeLists.txt [todo: what are the contents of this file???]
  • Open a terminal window
  • cd to your project directory
  • Create a build directory: mkdir Build
  • Change directory to the Build dir: cd Build
  • Run the command: ccmake ../
  • Follow the ccmake instructions. when done, your project is ready.
  • Refresh the eclipse project to show the new build directory.

Step 4: Create an eclipse run menu for cmake:

  • Select the “Run->External Tools->Show External Tools Dialog…” menu.
  • Create a new “Program” and call it Cmake.
  • In the “Location” text field, type the absolute path to cmake (i.e /usr/local/bin/cmake or whatever path your system uses).
  • In the “Working Directory” test field insert the following: “${project_loc}/Build” and in the Arguments section insert the following: “../”.
  • In the “Refresh” tab select The project containing the selected resources.
  • In the “Common” tab check the “External Tools” selection.
  • This will put a shortcut in the “Run” menu for you.
  • Click the Apply Button and then run.
  • CMake will now run on your project directory.

Step 5. Build the project using the command “Run -> External Tools -> cmake”

Next Up: Getting the project to generate both a windows exe and a linux executable.

see also:

About andy dingfelder

Andy is a CISO/CTO in the fintech sector with over 20 years of experience in Software Delivery and Team Leadership in multiple industry domains. Master's Degree (MPA) in Public Administration Information Systems and over 10 years of board governance experience for multiple organisations. Full bio is available at: and links available at or follow him on Twitter at Andy lives in the Wellington region, New Zealand with his wife and two daughters.
This entry was posted in C++, CDT, cmake, Eclipse, linux, windows. Bookmark the permalink.