[xsde-users] Building examples with the Eclipse CDT

Duncan.Perrett at elekta.com Duncan.Perrett at elekta.com
Fri Oct 2 10:24:57 EDT 2009


Boris,

Glad I asked!
Well done - that was exactly what I needed.
Have you been asked this before or are you just a whiz with IDEs and 
eclipse?

Obviously it works.
Hopefully I can now build a prototype project which uses xsde and convince 
my project team to use it.

Thank you for the superb support,

Duncan




From:
Boris Kolpackov <boris at codesynthesis.com>
To:
Duncan.Perrett at elekta.com
Cc:
xsde-users at codesynthesis.com
Date:
02/10/2009 10:42
Subject:
Re: [xsde-users] Building examples with the Eclipse CDT



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

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:

 
../hello.hxx;../hello.cxx;../hello-pskel.hxx;../hello-pskel.cxx;../hello-pimpl.hxx;../hello-pimpl.cxx
 
   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.

Boris




More information about the xsde-users mailing list