gerwindehaan / osgswig

Python bindings for OpenSceneGraph (auto-export from code.google.com/p/osgswig)
Other
1 stars 1 forks source link

Build Fails on OS X 10.8 #58

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm running OS X 10.8 with Xcode 4.4 wih the command line tools. I ran CMake 
2.8 to configure unix makefiles and here is what CMake reports about my system:

The C compiler identification is GNU 4.2.1
The CXX compiler identification is Clang 4.0.0
Checking whether C compiler has -isysroot
Checking whether C compiler has -isysroot - yes
Checking whether C compiler supports OSX deployment target flag
Checking whether C compiler supports OSX deployment target flag - yes
Check for working C compiler: /usr/bin/gcc
Check for working C compiler: /usr/bin/gcc -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: /usr/bin/c++
Check for working CXX compiler: /usr/bin/c++ -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Found OpenGL: /System/Library/Frameworks/OpenGL.framework  
Looking for XOpenDisplay in 
/usr/X11R6/lib/libX11.dylib;/usr/X11R6/lib/libXext.dylib
Looking for XOpenDisplay in 
/usr/X11R6/lib/libX11.dylib;/usr/X11R6/lib/libXext.dylib - found
Looking for gethostbyname
Looking for gethostbyname - found
Looking for connect
Looking for connect - found
Looking for remove
Looking for remove - found
Looking for shmat
Looking for shmat - found
Looking for IceConnectionNumber in ICE
Looking for IceConnectionNumber in ICE - found
Found X11: /usr/X11R6/lib/libX11.dylib
-- Warning Debug osg not found, OSG_LIBRARY_DEBUG using: OSG_LIBRARY
-- Warning Debug osgUtil not found, OSGUTIL_LIBRARY_DEBUG using: OSGUTIL_LIBRARY
-- Warning Debug osgDB not found, OSGDB_LIBRARY_DEBUG using: OSGDB_LIBRARY
-- Warning Debug osgText not found, OSGTEXT_LIBRARY_DEBUG using: OSGTEXT_LIBRARY
-- Warning Debug osgTerrain not found, OSGTERRAIN_LIBRARY_DEBUG using: 
OSGTERRAIN_LIBRARY
-- Warning Debug osgFX not found, OSGFX_LIBRARY_DEBUG using: OSGFX_LIBRARY
-- Warning Debug osgViewer not found, OSGVIEWER_LIBRARY_DEBUG using: 
OSGVIEWER_LIBRARY
-- Warning Debug osgGA not found, OSGGA_LIBRARY_DEBUG using: OSGGA_LIBRARY
-- Warning Debug osgSim not found, OSGSIM_LIBRARY_DEBUG using: OSGSIM_LIBRARY
-- Warning Debug osgShadow not found, OSGSHADOW_LIBRARY_DEBUG using: 
OSGSHADOW_LIBRARY
-- Warning Debug osgManipulator not found, OSGMANIPULATOR_LIBRARY_DEBUG using: 
OSGMANIPULATOR_LIBRARY
-- Warning Debug osgParticle not found, OSGPARTICLE_LIBRARY_DEBUG using: 
OSGPARTICLE_LIBRARY
-- Warning Debug osgAnimation not found, OSGANIMATION_LIBRARY_DEBUG using: 
OSGANIMATION_LIBRARY
OSG VERSION 3.0.1
Found OpenThreads: /usr/lib/libOpenThreads.dylib  
Found SWIG: /usr/local/bin/swig (found version "2.0.7") 
Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.2") 
Configuring done
Generating done

Although I don't care about the debug libraries, the build process fails at the 
cxx wrapper:

error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:249096:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:253878:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:258086:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:262797:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:267576:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:272440:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:278595:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:283535:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:287904:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:295346:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:300726:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:305877:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
/Users/deuscovrigus/devel/osgswig/buidU/src/python/osgPYTHON_wrap.cxx:315734:38:
 error: 
      taking the address of a temporary object of type 'ParentList' (aka
      'vector<osg::Group *>') [-Waddress-of-temporary]
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
                                     ^~~~~~~~~~~~~~~~~~~~~~
14 errors generated.
make[2]: *** [src/python/CMakeFiles/_osg.dir/osgPYTHON_wrap.cxx.o] Error 1
make[1]: *** [src/python/CMakeFiles/_osg.dir/all] Error 2
make: *** [all] Error 2

Original issue reported on code.google.com by deuscovr...@gmail.com on 31 Aug 2012 at 11:32

GoogleCodeExporter commented 9 years ago
Alas, 1/2 a year later and this error still shows up compiling on 10.8.
Basically, osgswig wont compile on osx with clang as compiler. 
What to do...

Original comment by jellefer...@gmail.com on 28 Dec 2012 at 1:27

GoogleCodeExporter commented 9 years ago
I can work around this compile error on Mac by inelegantly inserting the line

"%ignore getParents;"

in the file "src/osg.i". But I am still in the process of getting the full 
osgswig to build on my Mac with Mac OS 10.9.5.

Original comment by Christop...@gmail.com on 4 Sep 2014 at 4:48

GoogleCodeExporter commented 9 years ago
It turns out that my application actually uses the "getParents" method, so my 
previous comment workaround does not suffice for me. I ended up manually 
modifying the C++ code generated by SWIG. In all 14 places with an error. That 
was tedious. I hope some swig guru here can figure out how to do this 
automatically.

I ended up changing methods that look like this:...

*********************

SWIGINTERN PyObject *_wrap_LODRef_getParents(PyObject *SWIGUNUSEDPARM(self), 
PyObject *args) {
  PyObject *resultobj = 0;
  osg::ref_ptr< osg::LOD > *arg1 = (osg::ref_ptr< osg::LOD > *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  PyObject * obj0 = 0 ;
  osg::Node::ParentList *result = 0 ;

  if (!PyArg_ParseTuple(args,(char *)"O:LODRef_getParents",&obj0)) SWIG_fail;
  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_osg__ref_ptrT_osg__LOD_t, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LODRef_getParents" "', argument " "1"" of type '" "osg::ref_ptr< osg::LOD > const *""'");
  }
  arg1 = reinterpret_cast< osg::ref_ptr< osg::LOD > * >(argp1);
  result = (osg::Node::ParentList *) &(*arg1)->getParents();
  resultobj = swig::from(static_cast< std::vector<osg::Group*,std::allocator< osg::Group * > > >(*result));
  return resultobj;
fail:
  return NULL;
}

****************

...into something that can compile without error in clang, like this:

****************

SWIGINTERN PyObject *_wrap_LODRef_getParents(PyObject *SWIGUNUSEDPARM(self), 
PyObject *args) {
  PyObject *resultobj = 0;
  void *argp1 = 0 ;
  int res1 = 0 ;
  PyObject * obj0 = 0 ;

  if (!PyArg_ParseTuple(args,(char *)"O:LODRef_getParents",&obj0)) SWIG_fail;
  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_osg__ref_ptrT_osg__LOD_t, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LODRef_getParents" "', argument " "1"" of type '" "osg::ref_ptr< osg::LOD > const *""'");
  }
  { // 1 - moved result calculation and return, into its own local scope, between fail call, and fail label
    // 2 - moved declaration of "result" and "arg1" vars into local scope
    osg::ref_ptr< osg::LOD > *arg1 = (osg::ref_ptr< osg::LOD > *) 0 ;
    osg::Node::ParentList *result = 0 ;
    arg1 = reinterpret_cast< osg::ref_ptr< osg::LOD > * >(argp1);
    // 3 - create local variable "parents", to avoid taking address of temporary
    const osg::Node::ParentList& parents = (*arg1)->getParents();
    // 4 - take address of local variable, instead of temporary
    result = (osg::Node::ParentList *) &parents; 
    resultobj = swig::from(static_cast< std::vector<osg::Group*,std::allocator< osg::Group * > > >(*result));
    return resultobj;
  }
fail:
  return NULL;
}

*****************

It sure would be nice to find a non-manual way of doing this.

Original comment by Christop...@gmail.com on 5 Sep 2014 at 4:23