Tuesday, March 4, 2008

DGLWindow.cpp >> DGLWindow.o compilation error

I dug through the files. I can see that the Qt include files are getting
added, so the cmake stuff is probably OK.

Your build crashed on a compile, going from DGLWindow.cpp to DGLWindow.o, so
the libraries aren't involved, yet.

Looking at the error messages...

I looked at line 838 of qnamespace.h:
enum CursorShape {

I grepped through the Producer and OSG files and couldn't find a
CursorShape. Going through all of /usr/include got me a CursorShape in
/usr/include/X11/X.h:

#define CursorShape 0

so if the X11 file gets included before the qt include, the qt enum will become:
enum 0 {

clearly an error. I saw this comment in qevent.h, which had a similar error:
/*
If you get a strange compiler error on the line with None,
it's probably because you're also including X11 headers,
which #define the symbol None. Put the X11 includes after
the Qt includes to solve this problem.
*/

Another error:
qwindowdefs.h:147: error: reference to 'Display' is ambiguous
qwindowdefs.h:141: error: candidates are: typedef struct _XDisplay Display
Types:49: error: typedef struct Display Producer::Display

I think all the Display error complaints are because both X11 and Producer
define "Display". This has been a pain for me too. Probably the best thing
is rearrange the includes, as mentioned in the comment above, or just remove
the Producer code entirely.

Monday, February 25, 2008

DTK/DGL path problem

We are having a small problem when trying the CCallbackHelix example. We initially installed the different packages of DIVERSE (dgl, dtk...) under these directories:

/usr/local/devtools/dgl
/usr/local/devtools/dtk
etc

And we recently installed DIVERSE with CMakeLists.txt files following your instructions under
/usr/local/DIVERSE/install
built in: /usr/local/DIVERSE/build
and source in: /usr/local/DIVERSE/source

When we change something in ../source/dgl/lib/DGLWindow.cpp we do a "make install" in the build directory as you suggested us to do.

However, when making the example in " /usr/local/DIVERSE/source/dgl
/examples/CCallbackHelix " it is using the same old libraries from /usr/local/devtools...

This is what we get when making the CCallbackHelix example:

[root@groupe2 CCallbackHelix]# make
g++ -I/usr/local/devtools/dtk/include -I/usr/local/include -I/usr/local/devtools/Producer/include -I/usr/local/devtools/OpenThreads/include -M *.cpp > .depend
sed -e '/^[A-Za-z1-9]/s/^/.\//' .depend > .depend-temp
mv -f .depend-temp .depend
g++ -O3 -Wall -g -O3 -Wall -I/usr/local/devtools/dtk/include -I/usr/local/include -I/usr/local/devtools/Producer/include -I/usr/local/devtools/OpenThreads/include -c -o helix.o helix.cpp
g++ -o helix helix.o -O3 -Wall -g -O3 -Wall -L/usr/local/devtools/dtk/lib -ldtk -Wl,-rpath -Wl,/usr/local/devtools/dtk/lib -ldl -lpthread -lc -lm -lGL -lGLU -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -ldgl -L/usr/local/devtools/OpenSceneGraph-2.2.0/lib/ -Wl,-rpath -Wl,/usr/local/devtools/OpenSceneGraph-2.2.0/lib/ -lOpenThreads -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -lProducer -lm -L/usr/local/devtools/dtk/lib -ldtk -Wl,-rpath -Wl,/usr/local/devtools/dtk/lib -ldl -lpthread -lc -lm -lGL -lGLU -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -ldgl -L/usr/local/devtools/OpenSceneGraph-2.2.0/lib/ -Wl,-rpath -Wl,/usr/local/devtools/OpenSceneGraph-2.2.0/lib/ -lOpenThreads -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -lProducer -lProducer

I guess this is what we need to change (in bold). Is there something to have with "dgl-config" which is in the helix example Makefile ? What do you suggest?

> printenv

LD_LIBRARY_PATH=:/usr/local/devtools/OpenSceneGraph-2.2.0/lib/:/usr/lib:/usr/local/Trolltech/Qt-4.3.2/include/QtCore/:/usr/local/lib:/usr/local/include/:/usr/local/Trolltech/Qt-4.3.2/include/:/usr/local/DIVERSE/install/lib

COINDIR=/usr/local/devtools/Coin-2.4.5

OSG_LIB_DIR=/usr/local/devtools/OpenSceneGraph-2.2.0/lib/

FLTK_DIR=/usr/local/devtools/fltk-1.1.7

DPF_INSTALL_DIR=/usr/local/devtools/dpf-2.4.6

PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/groupe2/bin:/usr/kerberos/sbin::/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/sbin:/usr/local/devtools/dtk/bin/:/usr/local/Trolltech/Qt-4.3.2/bin:/usr/lib/qt-3.3/bin:/usr/local/DIVERSE//install/bin:/usr/local/netbeans-6.0/bin:/usr/local/devtools/OpenThreads/lib:/usr/local/devtools/Producer/lib:/usr/local/devtools/Producer/include:/usr/local/devtools/Producer/lib:/usr/local/devtools/OpenThreads/include:/usr/local/devtools/OpenThreads/lib:/usr/local/devtools/OpenSceneGraph-2.2.0/bin:/usr/lib/qt4/include/QtCore/:/usr/local/include:/home/groupe2/bin:/usr/kerberos/sbin::/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/sbin:/usr/local/devtools/dtk/bin/:/usr/local/Trolltech/Qt-4.3.2/bin:/usr/lib/qt-3.3/bin:/usr/local/devtools/OpenSceneGraph-2.2.0/bin/:/usr/local/DIVERSE//install/bin:/usr/local/netbeans-6.0/bin:/usr/local/devtools/OpenThreads/lib:/usr/local/devtools/Producer/lib:/usr/local/devtools/Producer/include:/usr/local/devtools/Producer/lib:/usr/local/devtools/OpenThreads/include:/usr/local/devtools/OpenThreads/lib:/usr/lib/qt4/include/QtCore/:/usr/local/include:/home/groupe2/bin:/usr/kerberos/sbin::/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/sbin:/usr/local/devtools/dtk/bin/:/usr/local/Trolltech/Qt-4.3.2/bin:/usr/lib/qt-3.3/bin:/usr/local/devtools/OpenSceneGraph-2.2.0/bin/:/usr/local/DIVERSE/install/bin:/usr/local/netbeans-6.0/bin:/usr/local/devtools/OpenThreads/lib:/usr/local/devtools/Producer/lib:/usr/local/devtools/Producer/include:/usr/local/devtools/Producer/lib:/usr/local/devtools/OpenThreads/include:/usr/local/devtools/OpenThreads/lib:/usr/lib/qt4/include/QtCore/:/usr/local/include:/home/groupe2/bin:/usr/kerberos/sbin::/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/sbin:/usr/local/DIVERSE/install/bin:/usr/local/Trolltech/Qt-4.3.2/bin:/usr/lib/qt-3.3/bin:/usr/local/devtools/OpenSceneGraph-2.2.0/bin/:/usr/local/DIVERSE/install/bin:/usr/local/netbeans-6.0/bin:/usr/local/devtools/OpenThreads/lib:/usr/local/devtools/Producer/lib:/usr/local/devtools/Producer/include:/usr/local/devtools/Producer/lib:/usr/local/devtools/OpenThreads/include:/usr/local/devtools/OpenThreads/lib:/usr/lib/qt4/include/QtCore/:/usr/local/include:/root/bin:/usr/kerberos/sbin::/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/sbin:/usr/local/DIVERSE/install/bin:/usr/local/Trolltech/Qt-4.3.2/bin:/usr/lib/qt-3.3/bin:/usr/local/devtools/OpenSceneGraph-2.2.0/bin/:/usr/local/DIVERSE/install/bin:/usr/local/netbeans-6.0/bin:/usr/local/devtools/OpenThreads/lib:/usr/local/devtools/Producer/lib:/usr/local/devtools/Producer/include:/usr/local/devtools/Producer/lib:/usr/local/devtools/OpenThreads/include:/usr/local/devtools/OpenThreads/lib:/usr/lib/qt4/include/QtCore/:/usr/local/include

PRODUCER_LIB_DIR=/usr/local/devtools/Producer/lib

PWD=/usr/local/DIVERSE/source/dgl/examples/CCallbackHelix

DIVERSE=/usr/local/DIVERSE/

PRODUCER_INC_DIR=/usr/local/devtools/Producer/include

OPENTHREADS_INC_DIR=/usr/local/devtools/OpenThreads/include

====================================================

I think the problem is that your PATH is set to use the dtk in devtools.

Try this:

which dtk-config

You want to see:

/usr/local/DIVERSE/install/bin
/dtk-config

But you'll probably see:

/usr/local/devtools/dtk/bin/dtk-config

dtk-config is used to set many of the build options, so if you point to the
wrong one, problems ensue.

You also want to see why the PATH has this in it:

/usr/local/DIVERSE//install/bin

It might be OK, but might also casue PATH to look only in /install/bin.

On the plus side, I do see

/usr/local/DIVERSE/install/bin

in your PATH too, so if you take the /usr/local/devtools/dtk/bin out of your
PATH, or put /usr/local/diverse/install/bin at the front of your PATH, and
rebuild, your should be OK.

Here's what my PATH is set to:

> echo $PATH
/usr/local/HEV/savg/dgl/scripts:/usr/local/HEV/savg/dgl/bin:/usr/local/HEV/savg/vtk/bin:/usr/local/HEV/savg/itk/bin:/usr/local/HEV/savg/dtk/scripts:/usr/local/HEV/savg/dtk/bin:/usr/local/HEV/savg/scripts:/usr/local/HEV/savg/bin:/usr/local/HEV/apps/diverse/installed/bin:/usr/local/HEV/apps/osg/osg-2.x/installed/bin:/usr/local/HEV/apps/coin/Coin-2.5.0/installed/bin:/usr/local/HEV/apps/bin:/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/X11R6/bin:/sbin:/usr/sbin:/usr/X11R6/bin

The directory of note is /usr/local/HEV/apps/diverse/installed/bin

All the "savg" stuff is locally written software. That is followed by
locally installed packages like DIVERSE, OSG and so forth, and lastly by the
standard system directories like /usr/bin.

Tuesday, February 12, 2008

Install DIVERSE with CMakeLists.txt files

I was looking in my directories but didn't find the CMakeLists files. Actually we installed the different packages of DIVERSE(dtk, dgl...) separately from the subversion directory (c.f http://diverse-vr.org/index.php?page=download ) in which they (CMakeLists files) do not appear.

However, I've seen on the sourceforge repository ( http://sourceforge.net/projects/diverse/ ) the DIVERSE3.0.0 package in which the CMakeLists.txt files are present, I guess this is the package which you are talking about and which probably, we should have installed.

====================================================

As a "developer", you'll want to use the version with the CMakeLists.txt
files. If you need any help installing it, please let me know.

One easy way to download it is to use svn with the command:
svn co https://diverse.svn.sourceforge.net/svnroot/diverse/trunk diverse-svn

and it'll put all of the code in a directory named diverse-svn. You can use
any other directory name you like if diverse-svn doesn't appeal to you.

We use this command to build it. (I also sent this in an earlier email- see
it for what "v" is for and so on. In particular, change CMAKE_INSTALL_PREFIX
to where you want it installed.)

\rm -rf build
mkdir build
cd build

v=`echo /usr/share/doc/nvidia-graphics*/include`
docs=ON
# this makes the Makefiles in the build directories
cmake \
-D CMAKE_INSTALL_PREFIX=$HEVROOT/apps/diverse/installed \
-D GLX_HEADER_PATH=${v} \
-D DADS_BUILD_DOCUMENTATION=${docs} \
-D DGL_BUILD_DOCUMENTATION=${docs} \
-D DTK_BUILD_DOCUMENTATION=${docs} \
-D OSG_INCLUDE_PATH=$HEVROOT/apps/osg/osg-2.x/installed/include \
-D OSG_LIBRARY_PATH=$OSG_LIB_DIR \
-D OSG_LIBRARY=$OSG_LIB_DIR/libosg.so \
../diverse-svn

# this compiles it in the build directory, and installs it in the install directory
make install

--------------------------
this is the cmake we did in the build directory

v=`echo /usr/include`
docs=ON

cmake -D CMAKE_INSTALL_PREFIX=/usr/local/DIVERSE/install/ -D GLX_HEADER_PATH=${v} -D DADS_BUILD_DOCUMENTATION=${docs} -D DGL_BUILD_DOCUMENTATION=${docs} -D DTK_BUILD_DOCUMENTATION=${docs} -D OSG_INCLUDE_PATH=/usr/local/devtools/OpenSceneGraph-2.2.0/include/ -D OSG_LIBRARY_PATH=$OSG_LIB_DIR -D OSG_LIBRARY=/usr/local/devtools/OpenSceneGraph-2.2.0/lib/libosg.so -D DGL_BUILD_WITH_OPENSCENEGRAPH=OFF ../source/

Getting Qt linked in DGL

Question:
In DGL, more precisely the file DGLWindow.cpp, we modified the create() function and replaced it with a Qt implemention.

We have included other header files such as . So as needed we modified the header file accordingly. As you told us in your last mail, we will need to rebuild everything.

Usually to build and run a Qt applications we used to do these commands:
> qmake -project
> qmake
> make
> ./qt_application

What should we do to build the DGLWindow.cpp (with the Qt implementation). Should we change the Makefile or other files such as Makefile.am/Makefile.in.

Apparently the Makefile is generated by the "configure" command in the root directory of DGL. Should we change anything in the configure file?


=================================================================
Answer:
To get Qt linked in, you'll need to mess with the cmake configure files.
This is a bit of a project.

You'll find the file CMakeLists.txt in many directories. These files define
what cmake will use and where it'll look to find stuff.

This command will tell me the files that contain the word "producer":

> find . -name CMakeLists.txt | xargs grep -i producer | sed -e 's/:.*$//' | uniq
./dgl/DSOs/dgl/CMakeLists.txt
./dgl/DSOs/dosg/CMakeLists.txt
./dgl/programs/dgl/dgl-readSta
te/CMakeLists.txt
./dgl/programs/dgl/dgl-waitExec/CMakeLists.txt
./dgl/programs/dgl/dgl-navControl/CMakeLists.txt
./dgl/programs/dosg/dosg-bounds/CMakeLists.txt
./dgl/programs/dosg/dosg-fly/CMakeLists.txt
./dgl/programs/dosg/dosg-transform/CMakeLists.txt
./dgl/programs/dcoin/dcoin-fly/CMakeLists.txt
./dgl/lib/dgl/CMakeLists.txt
./dgl/lib/dosg/CMakeLists.txt
./dgl/lib/dcoin/CMakeLists.txt
./dgl/lib/dvtk/CMakeLists.txt
./dgl/CMakeLists.txt
./dgl/examples/CCallbackHelix/CMakeLists.txt
./dgl/examples/quad/CMakeLists.txt
./dgl/examples/dosgfly/CMakeLists.txt
./dgl/examples/coinload/CMakeLists.txt

This isn't as bad as it looks. dgl/CMakeLists.txt is probably where you
should start, as it defines how to find Producer. The rest should just use
it, and the changes should be fairly mechanical.

In dgl/CMakeLists.txt, look for Producer. Most of the heavy lifting is from
lines 208-263. The first part tells cmake a name to look for, "Producer",
"Producerd" if running Windows, and a series of directories to look at to
find it, both the library and the include files. It looks in a mixture of
environment variables and hard-coded paths. If Qt has some environment
variables that tell the system where to find its library and include files,
just use those. If Qt has a program you can run to find out this
information (like fltk does, later in the file) just use this.

Later in the file, lines 306 & 404, Producer is added to the OSG & VTK
list of include files. You can add Qt there instead.

In other CMakeLists.txt files, the Producer include file and library are
added to the compiler flags, so just replace them with the Qt equivalents.

After you change the CMakeLists.txt files, rerun cmake to generate new
Makefiles.

Friday, February 8, 2008

Multithreading in DGLWindow.cpp

#ifdef _X11_IMPLEMENTATION
if (DGL::getApp()­>getMultiThreaded())
RenderSurface::initThreads();
#endif
#ifndef WIN32
if (!DGL::getApp()­>getMultiThreaded())
m_surface­>useConfigEventThread(false);
#endif

This appears to be related to threading, and what to do if you're running
multi-threaded. I think for now you shouldn't worry about threading, and
just comment it out. We can deal with it later, as Qt does its own
threading. You might want to make single threading the default by changing
DGL.cpp, line 39, from

bool DGL::m_multiThreaded = true;

to

bool DGL::m_multiThreaded = false;

and this way all the multi-threading code will be automatically skipped.

VisualChooser in DGLWindow.cpp

As near as I can tell, the VisualChooser is just a class where you set the
attrbutes of RenderSurface. It's used by Producer.

I see that DGLWindow is creating a VisualChooser and setting its attributes.
Later in the code it creates a new RenderSurface and assigns the
VisualChooser to it:

m_surface->setVisualChooser(m
_chooser);

Later it's used in the ralize() method, which actually creates the window.

m_surface->realize(m_chooser,
m_parentWindow->getRenderSurface()->getGLContext());

The code for that is specific to each platform- Window, X11, OS X. In the
X11 code, if the chooser isn't passed it uses the one you set it too
earlier.

Anyway, just think of it as a class that stores attributes of a window.

Modify a DGL program

If you wish to change the DGL program, you pretty much need to change the
code and rebuild.

The good news is that you don't have to rebuild everything if you just change
a class implementation or DSO.

For example, if you change DGLWindow.cpp, all you need to do is to cd to the
directory it's in and type "make install".

If you change an include file you pretty much need to rebuild everything.

Do you do out of core builds and installs? That's where you give cmake the
CMAKE_INSTALL_PREFIX option to tell it where to install stuff, and you give
cmake a final option about where to find the source.

For example, say you keep your source, build and install directories all
under a directory called $DIVERSE. It has a single directory, source, that
you downloaded DIVERSE into.

cd $DIVERSE
mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=$DIVERSE
/installed ../source

This will tell cmake to read files from the source directory and install in
the install directory.

If you change DGLWindow.cpp, you edit it in the source directory,
$DIVERSE/source/dgl/lib/dgl and run the "make install" command in the build
directory, $DIVERSE/build/dgl/lib/dgl

If you need to chanhe the include file, DGLWindow.h, you edit the source in
$DIVERSE/source/dgl/include/dgl. Build in $DIVERSE/build/dgl

Use the "j" option to make to do parallel makes. If you have two CPUs,
type: "make -j2 install" and things will go up to twice as fast.