[osg-users] running vrml plugin on 2.0

Jean-Sébastien Guay jean-sebastien.guay at polymtl.ca
Fri Jul 20 17:05:15 PDT 2007


Hello Bryan,

> "This application has failed to start because osg.dll was not found.
> Reinstalling the application may fix the this problem."
> Thanks again - I can smell the vrml inside my osgViewer ...

Ok, now we're down to fixing issues you would have for any usage of  
osgviewer - running the application itself implies it finding the DLLs  
which you just built.

Here's what I do, and what I suggest you do as well.

First of all, make sure that in the CMake configuration you specified  
a valid CMAKE_INSTALL_PREFIX. I set it to the same directory as the  
sources, so the binaries and libraries will be installed to  
...\OpenSceneGraph\bin and ...\OpenSceneGraph\lib respectively. That  
simplifies things a bit.

Then, when you build the sources from the CMake-generated project  
files, make sure you build the INSTALL project. That's the one that  
copies all the binaries, DLLs and libraries into the right directories  
(CMake builds them in temporary directories, and building the INSTALL  
target copies them to where you expect them to be).

Then, we need to set some environment variables to be able to find the  
binaries, DLLs, libraries and headers. On your start menu, right-click  
on My Computer and select Properties. On the Advanced tab, click the  
Environment Variables button. Under System Variables, I have created  
the following environment variables:

OSG_ROOT         --> point this to your OSG directory, the one that contains
                      src, include, etc.
OSG_INCLUDE_PATH --> %OSG_ROOT%\include
OSG_LIB_PATH     --> %OSG_ROOT%\lib
OSG_BIN_PATH     --> %OSG_ROOT%\bin
OSG_SAMPLES_PATH --> %OSG_ROOT%\share\OpenSceneGraph\bin
OSGHOME          --> %OSG_ROOT%

Then, edit the PATH environment variable (which can be found in the  
same place) and add ;%OSG_BIN_PATH%;%OSG_SAMPLES_PATH% to the end of it.

Then, open a new command prompt window (Start-Run, type cmd, click OK)  
and type for example

dir %OSG_INCLUDE_PATH%

You should get the contents of the ...\OpenSceneGraph\include  
directory. Then try to type

osgversion

You should get the current version of your recently compiled OSG,  
which in my case is

OpenSceneGraph Library 2.1.1

Now, you could then try to display your VRML file by going to the  
directory that contains it on the command line and typing

osgviewer <file>.wrl


Going back to the problem you reported above, the reason why it should  
now work is that by default, when an executable you run depends on a  
given DLL, Windows will search for that DLL first in the same  
directory as the executable, then on the system PATH. Some people  
advocate copying DLLs into the Windows\System32 directory, but I think  
that keeping them separate (in the OSG directory tree) and putting  
that on the PATH gives more control, and keeps the system cleaner.


Now, when you want to make a new project using the OSG, you should  
start a new project in Visual Studio, put $(OSG_INCLUDE_PATH) in  
"C/C++ - General - Additional Include Directories", $(OSG_LIB_PATH) in  
"Linker - General - Additional Library Directories", and list the OSG  
libraries your project needs in "Linker - Input - Additional  
Dependencies". For example, for a release build, it could depend on  
osg.lib, osgViewer.lib, osgDB.lib and osgUtil.lib. For a debug build,  
that would be osgd.lib, osgViewerd.lib, osgDBd.lib and osgUtild.lib.

Also, when starting a new project, I like copying the  
...\OpenSceneGraph\applications\osgViewer\osgViewer.cpp file into a  
new directory and starting from that. It should get you started with a  
known-good application which you can easily add to and modify to try  
things out as you discover the OSG.


For more testing, there is also a dataset that contains some standard  
files that OSG is tested against, which will allow you to test it a  
bit further. You can download that by SVN using

http://www.openscenegraph.com/svn/osg/OpenSceneGraph-Data/trunk

as the repository URL, or download it from

http://www.openscenegraph.com/osgwiki/pmwiki.php/Downloads/SampleDataset

Then, set another environment variable:

OSG_FILE_PATH --> the directory where you put the sample dataset

And then, from anywhere on the command line (meaning, you don't have  
to cd to the sample dataset directory) you can do

osgviewer cow.osg

(cow.osg being one of the standard test models in .osg format, open it  
in a standard text editor to see what the format looks like).


I hope I didn't lose you, and hopefully you can now get osgviewer to  
do some useful things and get started developing your own app. If not,  
I can always help you, so don't hesitate to ask.

J-S
-- 
______________________________________________________
Jean-Sebastien Guay     jean-sebastien.guay at polymtl.ca
                         http://whitestar02.webhop.org/

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




More information about the osg-users mailing list