Channels ▼
RSS

Web Development

Cross-Platform C/C++ Development with Eclipse CDT


Cross Compile Linux to Windows

Another option for building Windows executables with Eclipse on Linux is to use a cross compiler. To use this option, CDT must have the cross compile extension enabled, and a cross compiler must be installed. Under Ubuntu 10.10, installing the mingw32 package will bring in everything required to build the sample project with the MinGW cross compiler. Next, we'll install CDT cross compile support.

To install CDT cross compile support, navigate to Help → Install New Software... In the Work With textbox, type cdt to filter down to CDT settings and select the CDT option. Expand CDT Optional Features and check the C/C++ Cross Compiler Support option. Hit Next and follow the instructions to complete the installation (Figure 8).

Figure 8: Setting up Windows cross-compilation on Linux.

Installing the CDT cross compiler support provides new build configuration options. To see the new options, follow the previous instructions for creating a new build configuration. Under the Import Predefined dropdown box, two new options are available: Executable→Cross GCC→Debug, and Executable→Cross GCC→Release. Create a new build configuration called Debug-Win and select the Cross GCC→Debug option.

When this configuration is selected, you'll notice a new option in the project settings called Cross Settings. Open the project settings, select Cross Settings, and enter i586-mingw32msvc- into the prefix textbox. If the prefix box is left empty, the IDE will use the default system tools for linking and compiling (Figure 9).

Figure 9: The Cross Settings dialog box in Linux.

A Few Good Options

Eclipse offers a few options for creating cross-platform projects. It takes a bit of futzing, but developing between Linux and Windows works seamlessly once the project is setup. And there are other options that we didn't cover such as using GCC on Linux and Windows or creating makefiles by hand. Each option has its own set of quirks for dealing with include directories, maintainability, third-party libraries, and debugging.

In this article, we covered handling include directories and the options covered are arguably the easiest to maintain (since Eclipse automatically handles the makefile). If you want to debug on both platforms or use third-party libraries, there's a bit more work to do depending on the option chosen for cross-platform development. But we'll leave that for another time.


Ben DuPont is a software engineer. After 10 years of developing software and systems in a corporate environment, he founded Nebland Software, an independent software consulting company.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 
Dr. Dobb's TV