How to compile a program
This topic describes how to compile the example programs shipped with Iray. For a complete list of example programs see Example programs.
Overview
The neuray library release contains a set of example programs. It is recommended that you compile them and take them as a starting point for your own development.
The release contains a Makefile to build the examples on Linux and MacOS X platforms as well as solution files for Visual Studio 2008, 2010 and 2012 to build the examples on a Microsoft Windows platform.
You can integrate the neuray library easily in other build environments. You can even compile the examples by hand following the steps below. Let the environment variable $NEURAY_ROOT refer to the installation root of the neuray library.
Procedure
To compile an example program:
-
Copy the examples shipped with the release, make them writable, and switch to that directory:
001 cp -r $NEURAY_ROOT/examples . 002 chmod -R u+w examples 003 cd examples 004
-
Compile the program with the appropriate include path switch that points the compiler to the location of the neuray include files. A g++ compiler call could look like this:
001 g++ -I$NEURAY_ROOT/include -c example_start_shutdown.cpp -o example_start_shutdown.o -pthread 002
- Link the program with the library that provides dlopen().
A g++ linker call could look like this:
001 g++ -o example_start_shutdown example_start_shutdown.o -ldl -pthread 002
-
Make the shared library, also known as a DLL, known to your runtime system so that it is found when starting the example program. You can do this by placing the shared library in an appropriate location, and/or setting environment variables such as PATH (on Windows), LD_LIBRARY_PATH (on Linux), or DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH (on MacOS X).
Note: This step is platform and installation dependent.