15
© Copyright IBM Corporation 2006 Trademarks Migrate Visual Studio C and C++ projects to Eclipse CDT Page 1 of 15 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 Priyadarshini Sampath Ramakrishnan Kannan Karthik Subbian December 12, 2006 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. 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).

CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

© Copyright IBM Corporation 2006 TrademarksMigrate Visual Studio C and C++ projects to Eclipse CDT Page 1 of 15

Migrate Visual Studio C and C++ projects to EclipseCDTA step-by-step guide to moving Microsoft VS projects to Eclipse C/C++ Development Toolkit

Priyadarshini SampathRamakrishnan KannanKarthik Subbian

December 12, 2006

With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it isessential to study the migration of these projects to Eclipse, the open source IDE. This articleprovides 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.

The Eclipse Platform is an open source tool to assist you with moving a project from the design tothe test phase within a single development environment and without the need for separate toolsfor each stage. Eclipse was developed to assist the tools development community, concentratingon the core functionality of the tool instead of concentrating on the IDE itself. This is achievablebecause 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. Becauseof 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 deploymenton Windows are developed using Microsoft Visual Studio. This article provides a step-by-stepprocedure 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.

PrerequisitesEclipse 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).

Page 2: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

developerWorks® ibm.com/developerWorks/

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 2 of 15

Visual Studio/Platform SDKThis should be your current development IDE for C/C++ applications in Windows. The recentversion of Platform SDK (MSVC Express) is undergoing some changes that restricts you tobuilding executables in the conventional way using an nmake makefile. This article assumesyou are building the executable through a makefile. Be sure to identify the version you areusing.

See Related topics for links to download each.

Visual Studio and Eclipse comparedMicrosoft 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 isdependent on the gcc compiler and other open source tools.

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

C/C++ development compared on WindowsMicrosoft Visual Studio C/C++ Eclipse CDT

Nature of license Proprietary Open source

Programming languages supported Specific to C/C++ and Microsoft-supportedprogramming languages

Parallel different programming languages(COBOL, the Java programming language,and others), along with C/C++

SDLC phases supported Only coding Designing, coding, configuration management,testing, etc.

Debugging Complete debugging support No debugging support; debugging supportavailable only for gcc-compiled C code onplatforms other than Windows. MicrosoftDebugging Tools for Windows required

Resource editor Comprehensive resource editor No resource editor

Testing No testing tools as part of Visual Studio; third-party tools must be used

CppUnit can be used (see Related topics formore information)

MFC programming Development support for MFC application(wizard, code templates, etc.)

No support

Plug-in tools development Visual Studio 6 does not support any plugablesoftware components

Based on a plug-in architecture

Tools specific to Microsoft Windows Spy++, error look-up, ActiveX Container, andothers

No tools specific for Windows platforms

About CDTEclipse C++ Development Toolkit (CDT) is an extension to the Eclipse platform in the form of aplug-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

Page 3: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

ibm.com/developerWorks/ developerWorks®

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 3 of 15

among C++ developers on other platforms. CDT and the Web Tools plug-ins are the two mostpopular 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. Themost important is the CDT primary plug-in, which provides the core CDT capabilities. CDT DebugUI 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 externalexecutables 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 andcode assist make software development quick and easy. Syntax highlighting is configurable andcan be personalized to your individual taste. Code assist is the code completion feature that issimilar 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 Studioprojects to the Eclipse CDT Workbench.

VS to EclipseIn this section, we migrate a simple HelloWorld Win32 application developed using MicrosoftVisual C++ 6.

1. If you do not have an existing Win32 application, create a HelloWorld Win32 application usingVisual Studio. Create a makefile from the Projects > Export Makefile menu in Visual Studio.Figure 1. Create a HelloWorld Win32 application using Visual Studio

Page 4: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

developerWorks® ibm.com/developerWorks/

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 4 of 15

2. Start Eclipse and open the C/C++ perspective.a. Select Window > Open Perspective > Other

Figure 2a. Open the C/C++ perspective

b. Select C/C++ perspective

Figure 2b. Select C/C++ perspective

Note: C/C++ perspective will be listed in the SelectPerspective dialog only if the CDT plug-in is installed.

3. Create a standard C/C++ Make project via File > New > Standard Make C++ Project. Namethe project HelloEclipse in the Project Name edit box in the New Project dialog that appearsand click Finish.

Page 5: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

ibm.com/developerWorks/ developerWorks®

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 5 of 15

Figure 3a. It's HelloWorld time

Page 6: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

developerWorks® ibm.com/developerWorks/

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 6 of 15

Figure 3b. Name your project HelloEclipse

4. 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 notvisible, go to Window > ShowView > C/C++ project.

Page 7: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

ibm.com/developerWorks/ developerWorks®

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 7 of 15

Figure 4. Import the HelloWorld Visual Studio project files

5. 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.

Page 8: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

developerWorks® ibm.com/developerWorks/

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 8 of 15

Figure 5. Import the *.c*, *.h*,*.rc,*.ico and .mak files

6. Addition of environment variables

Page 9: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

ibm.com/developerWorks/ developerWorks®

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 9 of 15

Figure 6. Add environment variables

7. 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 environmentvariables to point to Visual Studio's include and lib paths. If you are using the platform SDK,point to its include and lib directories.

Page 10: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

developerWorks® ibm.com/developerWorks/

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 10 of 15

Figure 7. Point the Visual Studio include and lib paths in the right direction

8. Open the .mak file imported from the Visual Studio project and make the following changes:a. 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

b. Add the command for executing the application in the ALL: tag: @cmd /c $(OUTDIR)\$(EXENAME).exe

c. Define EXENAME=HelloWin

Page 11: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

ibm.com/developerWorks/ developerWorks®

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 11 of 15

Figure 8b. Define EXENAME

9. The next step is to create a new make target.a. Right-click on our current project and click on Create Make Target.

Figure 9a. Create a new make target

Page 12: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

developerWorks® ibm.com/developerWorks/

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 12 of 15

b. Create a make target for our project. "Target name" specifies any name you wish. "Maketarget" specifies the .mak file we just modified in the previous step. "Build command" isspecified by unchecking the Use default checkbox in the build command so the buildcommand 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

10. Double-click on the HelloEclipse target we created to build and run the Win32 application.

Page 13: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

ibm.com/developerWorks/ developerWorks®

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 13 of 15

Figure 10. Run the application

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

Challenges to Eclipse CDT as an IDE for Windows developmentLet's look at the various challenges posed by Eclipse CDT in various phases of the softwaredevelopment cycle.

DesignUML has become the de-facto standard for representing and designing software applicationsusing 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-demandmodel-code synchronization, and other helpful features. Though we have a UML plug-in forEclipse, there is no tight integration between UML to C/C++ in Eclipse platform today.

DevelopmentVisual Studio's most interesting feature is its resource editor. Whether it's the SDK or MFCresource 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 editorproject when generating .rc files for Windows development.

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

Page 14: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

developerWorks® ibm.com/developerWorks/

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 14 of 15

It is not viable today for you to migrate MSVC code totally to open source. In Linux, such anundertaking 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 CDTand 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 generatedby Microsoft compilers. As a result, it is a challenge to select CDT as a full-time developmentenvironment for Windows development. However, you can use Debugging Tools for Windows fordebugging 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 forEclipse is also available and can be used side by side with CDT for testing the CPP code. SeeRelated topics for a CppUnit tutorial.

Tools and other criteria

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

All open source tools, such as listdlls, process explorer, and task handler, can be considered toprovide 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 embraceEclipse as the development platform of the future. Nevertheless, porting Windows applicationsto use open source development tools like GCC, GDB, or GCC/GDB for Windows providingfunctionalities similar to Windows SDK is a nontrivial task today.

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

Page 15: CDT Migrate Visual Studio C and C++ projects to Eclipse · With most C/C++ projects on Windows® developed with Microsoft® Visual Studio®, it is essential to study the migration

ibm.com/developerWorks/ developerWorks®

Migrate Visual Studio C and C++ projects to Eclipse CDT Page 15 of 15

Related topics

• Read Brian Lee's Eclipse Project CDT (C/C++) Plugin Tutorial if you are new to CDT.• See the CppUnit wiki to learn about the C++ unit testing framework for Eclipse.• See the CDT wiki at Eclipse.org for a good starting page on all things CDT.• Eclipse C/C++ Development Tooling contains links to CDT documentation and downloads.• See CDT/designs/msvc at Eclipse.org to learn more about CDT and Microsoft Visual Studio.• Download the Eclipse Platform and get started with Eclipse now.• For an excellent introduction to the Eclipse platform, see "Getting started with the Eclipse

Platform.• See the latest Eclipse technology downloads at IBM alphaWorks.• Visit IBM developerWorks' Eclipse project resources to learn more about Eclipse.• Innovate your next open source development project with IBM trial software, available for

download or on DVD.

© Copyright IBM Corporation 2006(www.ibm.com/legal/copytrade.shtml)Trademarks(www.ibm.com/developerworks/ibm/trademarks/)