Setting up Eclipse CDT on Windows
I wanted to compile my own version of libxml2 on Windows using GCC and the Eclipse CDT environment. (You can also use the Visual Studio project included with libxml2, but I needed to compile with GCC.) You can follow the steps below to setup an environment the Eclipse CDT environment and build libxml2.
Install Java
Eclipse is built on Java, and so it needs the Java RTE.
- Download Java
- Run the installer to install
I downloaded the 64-bit version because I have a 64-bit version of Windows.
Install Eclipse CDT
Eclipse releases a number of packages for different development scenarios. The easiest way to get Eclipse for C/C++ development is to install Eclipse CDT (essentially Eclipse with C Development Tools).
- Download Eclipse CDT
- Unzip the contents and copy to
C:\Program Files
.
If you installed the same as I did, you should see the program C:\Program Files\Eclipse\eclipse.exe
Install Tools and Compiler
Eclipse CDT doesn’t come with a compiler or the tools needed to build the software. There are a few options here, and I elected to install MinGW.
- Download the MinGW installer
- Run the installer to install.
During installation, make sure you select everything you need. I selected everything except the Objective C, Fortran and Ada compilers.
Once you’ve installed MinGW, you have to add it to your path so that Eclipse can find it.
- Browse through
Control Panel > System and Security > System > Change Settings
- On the
Advanced
tab, clickEnvironment variables
-
If the user PATH environment variable exists append the following including the semicolon:
;C:\MinGW\bin;C:\MinGW\msys\1.0\bin
otherwise, create a new PATH environment variable, and set the value to
C:\MinGW\bin;C:\MinGW\msys\1.0\bin
At this point, everything is setup for use with any C/C++ project.
Create the Eclipse Project
My objective was to compile libxml2, so the following steps relate specifically to compiling libxml2. You can either drop off here, or continue to understand how to setup the Eclipse project.
- Download the latest libxml2
- Extract the contents to
C:\work\libxml2
. If you extracted as I suggested, you should see the fileC:\work\libxml2\README
- Start Eclipse. Set the workspace path to
C:\work
- In Eclipse, select File > New > C++ Project, and set the following settings, then click Next and Finish
- Set the project name to libxml2. The location should show as
C:\work\libxml2
and you should see a warning that a project already exists at that location - Set the project type to
GNU Autotools > Empty Project
- Set the project name to libxml2. The location should show as
- Set the compiler path using the following steps
- Select the libxml2 project. Select
Project > Properties
- Browse to
C/C++ General > Paths and Symbols
- Select
GNU C++
- Select the libxml2 project. Select
Build libxml2
Hopefully everything above worked. Now you’re ready to build.
1.Select Project > Build All
This will take a while, especially for the configure script, but when it’s done, you should have a built DLL.