Migrate Visual Studio C and C++ projects to Eclipse CDT

A step-by-step guide to moving Microsoft VS projects to Eclipse C/C++ Development Toolkit

With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration of these projects to Eclipse, the open source IDE. This article provides a brief step-by-step procedure for migrating Microsoft Visual Studio C/C++ (MSVC) projects to Eclipse. It compares and contrasts the benefits of MSVC and Eclipse CDT.

Share:

Priyadarshini Sampath (priyadarshini@in.ibm.com), Staff Software Engineer, IBM India

Priyadarshini SampathPriyadarshini Sampath is currently working on the Universal Systems Management project at India Systems and Technology Lab, IBM India. Prior to this, she worked in the Host Integration domain (HACP) for more than six years in IBM India Software Labs. Her work experience involves managing host-access client products such as PCOMM. She is an IBM Certified XML Solution Developer. She holds a bachelor's degree in computer science and engineering from Bharadhidasan University, India.



Ramakrishnan Kannan (rkrishnan@in.ibm.com), Staff Software Engineer, IBM India

Ramakrishnan KannanRamakrishnan Kannan works on host integration in IBM India Software Laboratory in Bangalore. He has been a developer for IBM personal communications and communication servers products. In addition to his development work, he works with customers in IBM Asia-Pacific region for Web service enablement of Host Applications. He has conducted webservices awareness session to business partners such as Infosys for Developerworks. He is an IBM Certified XML Solution Developer and Sun Certified Java Professional. His interests are host integration, distributed computing, SOA, and networking.



Karthik Subbian (ksubbian@in.ibm.com), Staff Software Engineer, IBM India

Karthik SubbianKarthik Subbian is currently building optimization products for manufacturing enterprises in IBM India Software Laboratory, Bangalore. He also has experience helping clients imanage their applications and migrate them to IBM platforms. His areas of interests in the software arena include Grid computing, XML, Web services and SOA. He has co-authored IBM Redbooks on Grid computing technology. He is an IBM Certified XML Solution Developer and Sun Certified Java Programmer.



12 December 2006

Also available in Chinese Russian

The Eclipse Platform is an open source tool to assist you with moving a project from the design to the test phase within a single development environment and without the need for separate tools for each stage. Eclipse was developed to assist the tools development community, concentrating on the core functionality of the tool instead of concentrating on the IDE itself. This is achievable because of programming model of Eclipse, which supports software building blocks called plug-ins.

Originally, Eclipse started with Java programming IDE, as it was the need of the hour. Because of its extensibility, it was embraced for developing applications for other programming languages, such as COBOL and C/C++.

The focus of this article is on C and C++ applications. Most C and C++ projects for deployment on Windows are developed using Microsoft Visual Studio. This article provides a step-by-step procedure for migrating Microsoft Visual Studio C/C++ (MSVC) projects to Eclipse. Along the way, we compare and contrast the benefits of using MSVC and Eclipse CDT.

Prerequisites

Eclipse Platform
Download Eclipse from the Eclipse Foundation.
Eclipse C++ Development Toolkit (CDT)
Get this Eclipse plug-in for C and C++ development (see About CDT).
Visual Studio/Platform SDK
This should be your current development IDE for C/C++ applications in Windows. The recent version of Platform SDK (MSVC Express) is undergoing some changes that restricts you to building executables in the conventional way using an nmake makefile. This article assumes you are building the executable through a makefile. Be sure to identify the version you are using.

See Resources for links to download each.


Visual Studio and Eclipse compared

Microsoft Visual Studio has a long history with wide use among Windows application developers. It is the leader in C and C++ Microsoft Windows application development, as well. By contrast, Eclipse CDT is relatively new and quite popular these days in the developers community. Eclipse CDT is designed to satisfy the developers of many OS platforms, such as Linux®, and is dependent on the gcc compiler and other open source tools.

There are many ways of comparing Eclipse with Visual Studio. One can compare the user interface (UI), architecture, cost, manageability, and many other criteria. Since this article looks at C and C++ development, we compare and contrast the strengths of both the tools with respect to C and C++ application development for Windows.

C/C++ development compared on Windows
Microsoft Visual Studio C/C++Eclipse CDT
Nature of licenseProprietaryOpen source
Programming languages supportedSpecific to C/C++ and Microsoft-supported programming languagesParallel different programming languages (COBOL, the Java programming language, and others), along with C/C++
SDLC phases supportedOnly codingDesigning, coding, configuration management, testing, etc.
DebuggingComplete debugging supportNo debugging support; debugging support available only for gcc-compiled C code on platforms other than Windows. Microsoft Debugging Tools for Windows required
Resource editorComprehensive resource editorNo resource editor
TestingNo testing tools as part of Visual Studio; third-party tools must be usedCppUnit can be used (see Resources for more information)
MFC programmingDevelopment support for MFC application (wizard, code templates, etc.)No support
Plug-in tools developmentVisual Studio 6 does not support any plugable software componentsBased on a plug-in architecture
Tools specific to Microsoft WindowsSpy++, error look-up, ActiveX Container, and othersNo tools specific for Windows platforms

About CDT

Eclipse C++ Development Toolkit (CDT) is an extension to the Eclipse platform in the form of a plug-in. This plug-in is available for download for all platforms. The open source nature of the plug-in with its user-friendliness makes it more popular not just among the Linux developers but also among C++ developers on other platforms. CDT and the Web Tools plug-ins are the two most popular Eclipse plug-ins. Nearly two out of three developers using CDT are Windows users.

CDT has subcomponents or plug-ins that are independent projects in the CDT community. The most important is the CDT primary plug-in, which provides the core CDT capabilities. CDT Debug UI provides the UI capabilities for the debug editors and views. CDT UI plug-in provides the UI-related features, views, editors, wizards, etc. CDT Debug provides core debugging capabilities. CDT Feature provides CDT Feature component. CDT core presents Core Model, CDOM, and other core components. CDT Launch provides launch mechanism for launching external executables and tools. CDT Debug MI is the application connector for MI-compatible debuggers.

CDT editors have several features that make them popular. For example, syntax highlighting and code assist make software development quick and easy. Syntax highlighting is configurable and can be personalized to your individual taste. Code assist is the code completion feature that is similar to the one in Visual Studio. Custom-defined code templates can be added to the plug-in, which can be used by code assist.

In the following sections, we will learn how to use CDT effectively to migrate the Visual Studio projects to the Eclipse CDT Workbench.


VS to Eclipse

In this section, we migrate a simple HelloWorld Win32 application developed using Microsoft Visual C++ 6.

  1. If you do not have an existing Win32 application, create a HelloWorld Win32 application using Visual Studio. Create a makefile from the Projects > Export Makefile menu in Visual Studio.
    Figure 1. Create a HelloWorld Win32 application using Visual Studio
    Create a HelloWorld Win32 application using Visual Studio
  1. Start Eclipse and open the C/C++ perspective.
    1. Select Window > Open Perspective > Other
      Figure 2a. Open the C/C++ perspective
      Open the C/C++ perspective
    1. Select C/C++ perspective
    Figure 2b. Select C/C++ perspective
    Select C/C++ perspective
    Note: C/C++ perspective will be listed in the Select Perspective dialog only if the CDT plug-in is installed.
  1. Create a standard C/C++ Make project via File > New > Standard Make C++ Project. Name the project HelloEclipse in the Project Name edit box in the New Project dialog that appears and click Finish.
    Figure 3a. It's HelloWorld time
    It's HelloWorld time
    Figure 3b. Name your project HelloEclipse
    Name your project HelloEclipse
  1. Now we have to import the files created by Visual Studio into Eclipse. Go to File > Import. Select Filesystem in the Import dialog and click Next. If the newly created project is not visible, go to Window > ShowView > C/C++ project.
    Figure 4. Import the HelloWorld Visual Studio project files
    Import the Visual Studio files
  1. Browse to the directory where the Visual Studio project was created, select the *.c*, *.h*,*.rc,*.ico and the .mak file to be imported and click Finish.
    Figure 5. Import the *.c*, *.h*,*.rc,*.ico and .mak files
    Import the *.c*, *.h*,*.rc,*.ico and .mak files
  1. Addition of environment variables
    Figure 6. Add environment variables
    Add environment variables
  1. Right-click on the project and select Properties. In the Properties for HelloEclipse dialog, select C/C++ Make Project on the left side, and add INCLUDE and LIB environment variables to point to Visual Studio's include and lib paths. If you are using the platform SDK, point to its include and lib directories.
    Figure 7. Point the Visual Studio include and lib paths in the right direction
    Point the Visual Studio include and lib paths in the right direction
  1. Open the .mak file imported from the Visual Studio project and make the following changes:
    1. Change the configuration (CFG) from Debug to Release so we get a release version of the application. It would look like CFG=HelloWin - Win32 Release.
      Figure 8a. Change the configuration from Debug to Release
      Change the configuration from Debug to Release
    1. Add the command for executing the application in the ALL: tag: @cmd /c $(OUTDIR)\$(EXENAME).exe
    2. Define EXENAME=HelloWin
    Figure 8b. Define EXENAME
    Define EXENAME
  1. The next step is to create a new make target.
    1. Right-click on our current project and click on Create Make Target.
      Figure 9a. Create a new make target
      Create a new make target
    1. Create a make target for our project. "Target name" specifies any name you wish. "Make target" specifies the .mak file we just modified in the previous step. "Build command" is specified by unchecking the Use default checkbox in the build command so the build command is nmake. To make the Make targets view visible, go to Window > Show View > Make Targets.
    Figure 9b. The make target should be HelloWin.mak
    The make target should be HelloWin.mak
  1. Double-click on the HelloEclipse target we created to build and run the Win32 application.
    Figure 10. Run the application
    Run the application

With VC++ 2005 Express, making many changes in the traditional Visual Studio C/C++, there is a project initiated at Eclipse to solve this issue. Visit Eclipse MSVC for details (see Resources).


Challenges to Eclipse CDT as an IDE for Windows development

Let's look at the various challenges posed by Eclipse CDT in various phases of the software development cycle.

Design

UML has become the de-facto standard for representing and designing software applications using object-oriented languages. IBM offers two Eclipse-based Java development tools: Rational® Application Developer and Rational Rose® XDE Developer for Java technology. Both offer model-driven development with UML support, Java code round-trip engineering, automatic or on-demand model-code synchronization, and other helpful features. Though we have a UML plug-in for Eclipse, there is no tight integration between UML to C/C++ in Eclipse platform today.

Development

Visual Studio's most interesting feature is its resource editor. Whether it's the SDK or MFC resource editor, both are used extensively to develop the static UI controls for the application. Today, Eclipse CDT offers no support to develop a UI. Consider using the Eclipse visual editor project when generating .rc files for Windows development.

Microsoft changes its compilers between versions, which makes it a challenge for Eclipse CDT to support the various versions of SDK tools Microsoft releases.

It is not viable today for you to migrate MSVC code totally to open source. In Linux, such an undertaking is complex. The SDK tools of Microsoft cannot run on open source, such as Linux. The SDK tools have to be run within the Windows emulator to make the SDK tools run on Linux.

However currently in Windows platform, developers with the help of platform SDK, Eclipse CDT and Debugging Tools for Windows can see Eclipse platform as an alternative for MS Visual Studio.

Debugging

Eclipse CDT relies on GNU Debugger, GDB. GDB is a source-level debugger for C, C++, Ada, and other languages. Neither Eclipse nor GDB understand the debugging information generated by Microsoft compilers. As a result, it is a challenge to select CDT as a full-time development environment for Windows development. However, you can use Debugging Tools for Windows for debugging side by side with Eclipse as a development environment.

Testing

CppUnit is the testing framework for C/C++ similar to JUnit for Java. The CppUnit plug-in for Eclipse is also available and can be used side by side with CDT for testing the CPP code. See Resources for a CppUnit tutorial.

Tools and other criteria

Apart from normal SDK development on Windows, Visual Studio supports many other developments, including DDK, .NET, WMI, Web development, IE component development, MDAC, and more. More contributions are expected in this space from Eclipse plug-in development community.

All open source tools, such as listdlls, process explorer, and task handler, can be considered to provide support inside Eclipse CDT, which can bridge this gap to a certain extent.


Conclusion

The growing popularity, versatility, and open source nature of Eclipse motivates many to embrace Eclipse as the development platform of the future. Nevertheless, porting Windows applications to use open source development tools like GCC, GDB, or GCC/GDB for Windows providing functionalities similar to Windows SDK is a nontrivial task today.

However, Eclipse is an effective open source alternative to visual studio when we consider the entire SDLC phases. With more and more plug-ins supported in Eclipse for C/C++ application development in Windows, Eclipse CDT may become a default IDE for C/C++ development for Windows.

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Open source on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source
ArticleID=182670
ArticleTitle=Migrate Visual Studio C and C++ projects to Eclipse CDT
publish-date=12122006