DOM guide: Setting up

From COLLADA Public Wiki
Jump to navigation Jump to search

This article describes how to obtain the COLLADA DOM and use it in a program.

Downloading the COLLADA DOM

The latest official release of the DOM is version 2.0, which is available as a download on Sourceforge. A zip containing the source is available, as are binary packages for several platforms. The binary downloads only include the headers and libs necessary for building an app. You won't be able to rebuild or debug the DOM using the binary packages.

You can also get the DOM from the svn repo on Sourceforge. For that you'll need a Subversion client. Open up a shell and run

svn co https://collada-dom.svn.sourceforge.net/svnroot/collada-dom/tags/2.0 colladadom

to check out version 2.0, or run

svn co https://collada-dom.svn.sourceforge.net/svnroot/collada-dom/trunk colladadom

to check out the trunk.

Windows

Building the DOM

Project and solution files for Visual Studio can be found in

<dom-path>\projects

Currently only VS 2005 projects are provided, but VS 2008 can also be used by running Visual Studio's upgrade wizard. Open dom.sln and build the 'dom' project for the DLL DOM, or build 'dom-static' for the DOM static lib. The output goes to the <dom-path>\build folder.

Building client applications

Setting up include directories

Add the following information to your project:

  • Add the following lines to the Additional include directories field in the General tab for the C/C++ project configuration settings:
<dom-path>\include
<dom-path>\include\1.4

Linking with the COLLADA DOM static lib

  • Add the following lines to the Additional library directories field in the General tab for the Linker project configuration settings:
<dom-path>\build\vc8-1.4 (release) or <dom-path>\build\vc8-1.4-d (debug)
<dom-path>\external-libs\libxml2\win32\lib
<dom-path>\external-libs\pcre\lib\vc8
  • Add the following lines to the Additional Dependencies field in the Input tab for the Linker project configuration settings:
libcollada14dom20-s.lib (release) or libcollada14dom20-sd.lib (debug)
libxml2_a.lib
zlib.lib
wsock32.lib
pcre.lib (release) or pcre-d.lib (debug)
pcrecpp.lib (release) or pcrecpp-d.lib (debug)

Linking with the COLLADA DOM DLL

  • Add the following line to the Preprecessor Definitions field in the Preprocessor tab for the C/C++ project configuration settings:
DOM_DYNAMIC
  • Add the following to the Additional library directories field in the General tab for the Linker project configuration settings:
<dom-path>\build\vc8-1.4 (release) or <dom-path>\build\vc8-1.4-d (debug)
  • Add the following to the Additional Dependencies field in the Input tab for the Linker project configuration settings:
libcollada14dom20.lib (release) or libcollada14dom20-d.lib (debug)

Linux

Preparing the external libraries

You need both the libxml and PCRE headers and libs installed to build the DOM. For the domTest program you also need the Boost Filesystem library installed. These libraries are fairly popular and it's expected that most Linux distributions will provide them via the package manager, so these libs aren't provided with the DOM like they are on Windows and Mac. For example, in Ubuntu you could install these libraries using aptitude:

aptitude install libxml2-dev libpcre3-dev libboost-filesystem-dev

Building the DOM

On Linux the DOM builds as both a static lib (.a) and a shared lib (.so). All output goes to the <dom-path>/build folder.

Go to the COLLADA DOM directory and run

make

This builds a release version of the DOM. More extensive documentation of our make build system is available in the <dom-path>/make/readme file included with the DOM.

Building client applications

Building a client app

If you have a file test.cpp that works with the COLLADA DOM, you can build it to use the static DOM lib with g++ like this:

g++ -I<dom-path>/include -I<dom-path>/include/1.4 test.cpp <dom-path>/build/linux-1.4/libcollada14dom.a -lxml2 -lpcre -lpcrecpp -o test

Or you can build to use the DOM shared lib:

g++ -I<dom-path>/include -I<dom-path>/include/1.4 test.cpp <dom-path>/build/linux-1.4/libcollada14dom.so -lxml2 -lpcre -lpcrecpp -o test

Installing the DOM for easier setup

When building client applications on Linux, it's convenient to install headers and libs to a standard system path, such as /usr[include,lib] or /usr/local[include,lib]. To install, go to the COLLADA DOM directory and run

make install

which puts the headers in /usr/local/include and the libs in /usr/local/lib. The make install rule also takes a 'prefix' argument that allows you to specify where to install to. See the make readme for more info. You can uninstall by running

make uninstall

The DOM will remember where you installed to and uninstall itself from that location.

The main benefit of this is that you can make sure the DOM shared lib is in your PATH, so you can easily run a program that links against the shared lib.

Mac

Note that the only officially supported version of OS X is 10.5 (Leopard), but the DOM used to work on Tiger fine and might still work.

Building the DOM

The Mac uses the same make build architecture as Linux and PS3. Simply run 'make' in the DOM folder to build a release framework. See the make readme for more info. The build output goes to <dom-path>/build.

'make install' is also available to copy the DOM framework to /Library/Frameworks.

Building client applications

Using Xcode

In Xcode add the DOM framework to your project (Project->Add to Project). In the build configuration of your target, add <dom-path>/Collada14Dom.framework/Headers to Header Search Paths. For a debug build the framework name is Collada14Dom-d.framework, so adjust paths accordingly.

Using Make and gcc

Additional gcc compiler arguments:

-I<dom-path>/Collada14Dom.framework/Headers

Additional linker arguments:

-F<dom-path> (if the DOM isn't in a standard path like /Library/Frameworks)
-framework Collada14Dom

For a debug build the framework name is Collada14Dom-d.framework, so adjust the gcc arguments accordingly.

Using different installation locations for DOM framework

You can install the DOM framework in a different location than /Library/Frameworks. For example, you might use it as an embedded framework in your application bundle. To avoid linker errors, you can either change the Installation Directory build setting in the DOM Xcode project and rebuild the project, or use otool and install_name_tool to modify an existing framework. For more information, see

man otool

and

man install_name_tool

Setting up on PS3

The DOM works on the Cell OS Level 2, for example to be used in a PS3 game. Building the DOM to run on the PS3 is exactly the same as building it to run on Linux, except that you pass the parameter PLATFORM_NAME=ps3 on the make command line. The other supported make parameters are the same as for the Linux build.

There are a few other differences between the DOM on PS3 and the DOM on Linux:

  • Cell OS Level 2 doesn't support shared libraries, so only static DOM libs are built.
  • The DOM on PS3 uses TinyXml instead of libxml for XML parsing. You'll need to link TinyXml into your app.

PS3 libraries for PCRE and TinyXml are provided in the external-libs folder.

It should be possible to build the PS3 version of the DOM on Windows using the GNU makefiles via MinGW/MSYS, but this hasn't been tested.


COLLADA DOM - Version 2.4 Historical Reference
List of main articles under the DOM portal.
User Guide chapters:  • Intro  • Architecture  • Setting up  • Working with documents  • Creating docs  • Importing docs  • Representing elements  • Working with elements  • Resolving URIs  • Resolving SIDs  • Using custom COLLADA data  • Integration templates  • Error handling

Systems:  • URI resolver  • Meta  • Load/save flow  • Runtime database  • Memory • StringRef  • Code generator
Additional information:  • What's new  • Backward compatibility  • Future work
Terminology categories:  • COLLADA  • DOM  • XML