OpenSceneGraph icon indicating copy to clipboard operation
OpenSceneGraph copied to clipboard

Compile error when Building Openscenegraph 3.4

Open callahanp opened this issue 3 years ago • 4 comments

A fresh build of Open Scene Graph version 3.4 ended with a compile error on Ubuntu 22.10 because

bool ObjectCache::ClassComp::operator() was not declared const.

The declaration in openscenegraph/include/osgDB/ObjectCache and the definition in openscenegraph/src/osgDB/ObjectCache.cpp need a minor change on the version 3.4 branch.

in both files, bool ObjectCache::ClassComp::operator() (const ObjectCache::FileNameOptionsPair& lhs, const ObjectCache::FileNameOptionsPair& rhs) changes to: bool ObjectCache::ClassComp::operator() (const ObjectCache::FileNameOptionsPair& lhs, const ObjectCache::FileNameOptionsPair& rhs) const

The error: /work/fg/stable/openscenegraph/src/osgDB/ObjectCache.cpp:72:68: required from here /usr/include/c++/12/bits/stl_tree.h:770:15: error: static assertion failed: comparison object must be invocable as const 770 | is_invocable_v<const _Compare&, const _Key&, const _Key&>, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/12/bits/stl_tree.h:770:15: note: ‘std::is_invocable_v<const osgDB::ObjectCache::ClassComp&, const std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, osg::ref_ptr<const osgDB::Options> >&, const std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, osg::ref_ptr<const osgDB::Options> >&>’ evaluates to false make[2]: *** [src/osgDB/CMakeFiles/osgDB.dir/build.make:440: src/osgDB/CMakeFiles/osgDB.dir/ObjectCache.cpp.o] Error 1

callahanp avatar Oct 21 '22 04:10 callahanp

Same issue, any updates?

double-fault avatar Jun 16 '23 05:06 double-fault

You are welcome to fix and submit a fix to this project. I know Robert has moved onto other things but I'm sure whomever is managing this repository would take it.

minghia avatar Jun 29 '23 11:06 minghia

OpenSceneGraph-3.4.x is pretty ancient. Might I suggest just use OpenSceneGraph-3.6.x?

robertosfield avatar Jun 29 '23 11:06 robertosfield

Are you sure you are using the 3.4.X branch? My copy of the 3.4.1 branch doesn't have ClassComp doesn't exist but does in the copy of 3.6.5 I have on my system. The definition of struct ClassComp in osgDB/ObjectCache is: struct ClassComp { bool operator() (const ObjectCache::FileNameOptionsPair& lhs, const ObjectCache::FileNameOptionsPair& rhs) const; };

so it has the desired change.

minghia avatar Jun 29 '23 11:06 minghia