Hi,

We're trying to use OSG within a dynamically loaded plugin in our code. Whenever we call dlclose() on our plugin, however, shortly after main() returns we segfault. I was wondering if anyone who's worked with OSG has heard of this kind of problem before?

I've attached an example of what we're doing which reproduces our problem. We're running OSG 1.2.

--
Philip Lowman
Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com
#include <dlfcn.h>
#include <cassert>
#include <iostream>

typedef void (*cfunc)();

using namespace std;

int main(int argc, char *argv[])
{
   char *error = 0;
   void *handle = 0;

   handle = dlopen("osgtest.so", RTLD_GLOBAL | RTLD_NOW);
   error = dlerror();
   if(error)
   {
      cout << "error calling dlopen()" << endl;
      cout << error << endl;
      return 1;
   }

   assert(handle);
   dlerror();
   cfunc entry = (cfunc) dlsym(handle, "initialize");
   error = dlerror();
   if(error)
   {
      cout << error << endl;
      return 1;
   }

   assert(entry);
   entry();

   assert( dlclose(handle) == 0);

   return 0;
}
default: main osgtest.so

main: main.cc
        g++ -o $@ main.cc -ldl

osgtest.so : osgtest.o
        g++ -shared -Wl,-soname,osgtest -o $@ osgtest.o -losg -losgDB

clean:
        rm -f main
        rm -f *.o
        rm -f osgtest.so
#include <osg/Group>
#include <osg/Node>
#include <osgDB/ReadFile>

#include <cassert>
#include <iostream>

using namespace std;

extern "C" void initialize()
{
   cout << "in initialize()" << endl;

   osg::ref_ptr<osg::Group> group;
   osg::ref_ptr<osg::Node> node;

   node = osgDB::readNodeFile("cow.osg");
   if(node.get())
   {
      group = node->asGroup();
      assert(group.get());
      cout << "Loaded the cow" << endl;
   }
   else
   {
      cout << "Unable to load cow.osg" << endl;
      return;
   }
}

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to