[xsde-users] Building examples with the Eclipse CDT

Boris Kolpackov boris at codesynthesis.com
Fri Oct 2 05:52:06 EDT 2009

Hi Duncan,

Duncan.Perrett at elekta.com <Duncan.Perrett at elekta.com> writes:

> Now I want to build and execute with Eclipse CDT under linux and gcc.
> Can I use a "managed make" style project and add some build settings or do 
> I have to rely on the examples' resident makefiles?

I gave it a try and it works almost perfectly with managed make, 
except for a little snag (more on this below). Here are the step-
by-step instruction for setting the example/cxx/hybrid/hello/ 
example with Eclipse CDT. You can use the same approach for other
examples or your application. Here I assume XSD/e is installed in
/opt/xsde and that the libxsde library was built using the supplied

1. Create a directory for the hello example and copy driver.cxx,
   hello.xml, and hello.xsd into it. Do not copy the makefile.

2. In Eclipse, do File->New->C++ Project. Type the directory
   name from step 1 as project name so that the Location field
   points to the directory created in step 1. Click Next then
   Finish. At this stage Eclipse will try to build driver.cxx
   which will result in compile errors. This is expected since
   we haven't generated the C++ files from the schema yet.

3. In Project Explorer right-click on hello.xsd and select 
   Properties. Select C/C++ Build->Settings, select Build Steps
   tab, and change Configuration to All. Change "Disable Custom
   Build Step" to "Apply Custom Build Step Overriding Other Tools".
   Leave Additional Input Files field blank. In output file names,
   list all the generated C++ files with the '../' path, separated
   by semicolon. In our case it will be:

   In the Command field put the XSD/e compiler command line that is
   used to compile the schema. Also add '--output-dir ..' and use the
   '../' path for the schema file. In our case it will be:

   /top/xsde/bin/xsde cxx-hybrid --generate-parser --generate-aggregate --output-dir .. ../hello.xsd

   In the Description field put something like "xsde hello.xsd" or
   "compiling hello.xsd". Click Ok to close the dialog.

4. In Project Explorer right-click on the project name and select
   Properties. Select C/C++ General->Paths and Symbols, select
   GNU C++, select Includes tab, and change Configuration to All.
   Add the path for the libxsde library headers, /opt/xsde/libxsde 
   in our case. Change to the Library Paths tab and add the path
   to the libxsde.a library, /opt/xsde/libxsde/xsde in our case.
   Click Apply.

   Change to C/C++ Build->Settings->GCC C++ Linker->Libraries.
   Add 'xsde' to the Libraries list. Click Ok to close the dialog.

5. Now Eclipse knows how to build the generated C++ files from the
   schema. Unfortunately, Eclipse is not smart enough to figure out
   that some files included in driver.cxx are those generated C++ 
   files and it could have successfully compiled driver.cxx if only
   it compiled the schema first.

   So when we don't have the generated C++ files, we need to 
   "bootstrap" the project by explicitly compiling them. Once the
   files are generated, Eclipse will figure out all the dependencies
   and everything will work as expected (that is, if we modify
   hello.xsd, Eclipse will know to first recompile hello.xsd and
   only then recompile driver.cxx).

   The easiest way to do this bootstrapping is to add a special
   target that will trigger the schema compilation. Go to Project->
   Make Targets->Create. In Target Name type something like Bootstrap.
   Then uncheck the "Same as the target name" box and enter the name
   of the generated file with the '../' path, one file per schema
   is sufficient. In our case it will be ../hello.hxx. Click Ok
   to close the dialog.

6. Now we can bootstrap the project by doing Project->Make Targets->
   Build and selecting the Bootstrap target.

   After that we can continue with normal builds.

Let me know if you run into any issue with this.


More information about the xsde-users mailing list