info-inventor
[Top] [All Lists]

Strange behavior of SoXt:init or am I missing something?

To: info-inventor@xxxxxxxxxxx
Subject: Strange behavior of SoXt:init or am I missing something?
From: Haykel ben Jemia <haykel@xxxxxxxxxxxxxxx>
Date: Sat, 4 Nov 2000 22:33:52 +0100
Cc: Haykel ben Jemia <haykel@xxxxxxxxxxxxxxx>
Sender: owner-inventor@xxxxxxxxxxx
Hi,
I'm learning to program with X Windows and OpenInventor and I encountered the
following problem:
 * the following test programs test1 and test2 both compile, but while test2
is working fine, I receive the following error message with test1:

Error: attempt to add non-widget child "DropSiteManager" to parent "test1" 
which supports only widgets

 * I noticed after some experiments that I can make test1 work if I add a
widget library to link the program with when compiling (like: -lXm, -lXaw or
-lXaw3d), without even changing the code. Is this normal?? Why is test2
working even if I don't link with one of these widget libs?? Why is the code
compiling if one of these libraries is needed??

And what I REALLY DON'T understand is: AREN'T BOTH PROGRMAS DOING EXACTLY THE
SAME THING???

My System:
Linux Mandrake 7.2 RC-1
Kernel: 2.2.17-21mdk
Inventor: sgi-OpenInventor-devel-2.1.5-6.i386.rpm
X Server: XFree86-server-4.0.1-26mdk
Graphics chip: NVIDIA TNT2

--------------------- test1 -----------------------------
#include <iostream.h>
#include <Inventor/Xt/SoXt.h>
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
#include <Inventor/nodes/SoCone.h>

int main(int argc, char *argv[]) {
  XtAppContext appContext;

  cout << "Test 1: XtAppInitialize + SoXt::init(widget)" << endl;

  Widget mainApp = XtAppInitialize(&appContext,
                                   "TestClass",
                                   NULL, 0,
                                   (int *) &argc, argv,
                                   NULL,
                                   NULL ,0);
  SoXt::init(mainApp);

  SoXtExaminerViewer *view = new SoXtExaminerViewer(mainApp);
  view->setSceneGraph(new SoCone);
  view->show();

  SoXt::show(mainApp);

  SoXt::mainLoop();
  return 0;
}
--------------------- test1 -----------------------------

--------------------- test2 -----------------------------
#include <iostream.h>
#include <Inventor/Xt/SoXt.h>
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
#include <Inventor/nodes/SoCone.h>

int main(int argc, char *argv[]) {

  cout << "Test 2: SoXt::init(argv[0]) only" << endl;

  Widget mainApp = SoXt::init(argv[0], "TestClass");

  SoXtExaminerViewer *view = new SoXtExaminerViewer(mainApp);
  view->setSceneGraph(new SoCone);
  view->show();

  SoXt::show(mainApp);

  SoXt::mainLoop();
  return 0;
}
--------------------- test2 -----------------------------

--------------------- Makefile --------------------------
all: test1 test2

test1: test1.c++
        g++ -o test1 test1.c++ -I/usr/X11R6/include -lInventorXt \
#       -L/usr/X11R6/lib -lXaw
# Uncomment the line above to make test1 work! Why ????

test2: test2.c++
        g++ -o test2 test2.c++ -I/usr/X11R6/include -lInventorXt
# test2 doesn't need such a line!!
--------------------- Makefile --------------------------

Please send a copy of your answer to me directly.
Thank you for your help,
Haykel
-- 
       _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
      _/ Haykel Ben Jemia            _/_/_/_/_/
     _/ Mail  : Haykel@xxxxxxxxxxxxxxx _/
    _/ Voice : ++49-030-306 28 85   _/_/
   _/ ICQ : 5130782_/_/_/_/_/_/_/_/_/_/
    _/_/_/_/_/_/_/_/

<Prev in Thread] Current Thread [Next in Thread>