Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

/usr/include/c++/v1/map:837:5: error: static_assert failed "Allocator::value_type must be same type as value_type"

340 views
Skip to first unread message

Otacílio

unread,
Jun 14, 2016, 12:05:51 AM6/14/16
to freebsd...@freebsd.org
I'm getting this error when I try compile the ORB-SLAM2 library. Some
one can give me a hint about it?


/usr/include/c++/v1/map:837:5: error: static_assert failed
"Allocator::value_type must be same type as value_type"
static_assert((is_same<typename allocator_type::value_type,
value_type>::value),



Thanks a lot.

-Otacílio

_______________________________________________
freebsd...@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hacke...@freebsd.org"

Dimitry Andric

unread,
Jun 14, 2016, 5:15:23 PM6/14/16
to Otacílio, freebsd...@freebsd.org
On 14 Jun 2016, at 06:05, Otacílio <otacil...@bsd.com.br> wrote:
>
> I'm getting this error when I try compile the ORB-SLAM2 library. Some one can give me a hint about it?
>
>
> /usr/include/c++/v1/map:837:5: error: static_assert failed "Allocator::value_type must be same type as value_type"
> static_assert((is_same<typename allocator_type::value_type, value_type>::value),

Typically, this is because the allocator for std::map must use a const
key, and libc++ now checks for this with a static assertion.

See for example this fix for www/node:
https://svnweb.freebsd.org/ports/head/www/node/files/patch-deps_v8_src_compiler_instruction.h?view=markup&pathrev=412412

-Dimitry

signature.asc

Otacílio

unread,
Jun 14, 2016, 9:37:18 PM6/14/16
to ADAM David Alan Martin, freebsd...@freebsd.org
Em 14/06/2016 14:25, ADAM David Alan Martin escreveu:
> Hi,
>
>
> On 06/14/16 00:05, Otacílio wrote:
>> I'm getting this error when I try compile the ORB-SLAM2 library. Some
>> one can give me a hint about it?
>>
>>
>> /usr/include/c++/v1/map:837:5: error: static_assert failed
>> "Allocator::value_type must be same type as value_type"
>> static_assert((is_same<typename allocator_type::value_type,
>> value_type>::value),
> It sounds like the code is using an STL allocator in a way which worked
> prior to C++11/14 changes to allocators. Could you post more of the
> compiler output? Is this a port in the ports tree? If not, could you
> point me at the source of ORB-SLAM2?
>
>> Thanks a lot.
>>
>> -Otacílio
> Regards,
>
Dear

I have created some ports to compile orbslam2 to FreeBSD. They are not
finished until now, but so many work is done and can be very help to
someone that wants compile orbslam2 on FreeBSD. I did this ports:

graphics/DBoW2
graphics/DLib
graphics/Pangolin
graphics/libQGLViewer
graphics/orbslam2
math/g2o

It is necessary that OpenCV be compiled with NONFREE enabled. And I have
applied a patch to math/openblas/Makefile.

I can send to you this ports if you can help me to solve this problem.
I don't have expertise so solve this alone. Bellow is the error message:

[]'S

-Otacílio

In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:21:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/LoopClosing.h:24:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/KeyFrame.h:24:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/MapPoint.h:25:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/Frame.h:27:
In file included from /usr/local/include/DBoW2/BowVector.h:14:
/usr/include/c++/v1/map:837:5: error: static_assert failed
"Allocator::value_type must be same type as value_type"
static_assert((is_same<typename allocator_type::value_type,
value_type>::value),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:436:21:
note: in instantiation of template class
'std::__1::map<ORB_SLAM2::KeyFrame *, g2o::Sim3,
std::__1::less<ORB_SLAM2::KeyFrame *>,
Eigen::aligned_allocator<std::__1::pair<const ORB_SLAM2::KeyFrame *,
g2o::Sim3> > >' requested here
KeyFrameAndPose CorrectedSim3, NonCorrectedSim3;
^
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:466:29:
error: no viable overloaded operator[] for type 'KeyFrameAndPose' (aka
'map<ORB_SLAM2::KeyFrame *, g2o::Sim3, std::less<KeyFrame *>,
Eigen::aligned_allocator<std::pair<const KeyFrame *, g2o::Sim3> > >')
NonCorrectedSim3[pKFi]=g2oSiw;
~~~~~~~~~~~~~~~~^~~~~
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:470:39:
error: use of undeclared identifier 'mit'; did you mean 'min'?
for(KeyFrameAndPose::iterator mit=CorrectedSim3.begin(),
mend=CorrectedSim3.end(); mit!=mend; mit++)
^~~
min
/usr/include/c++/v1/algorithm:2562:1: note: 'min' declared here
min(const _Tp& __a, const _Tp& __b, _Compare __comp)

Otacílio

unread,
Jun 14, 2016, 9:41:18 PM6/14/16
to Dimitry Andric, freebsd...@freebsd.org
I think that this problem is more difficult that the example. Bellow is
the error message:

In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:21:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/LoopClosing.h:24:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/KeyFrame.h:24:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/MapPoint.h:25:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/Frame.h:27:
In file included from /usr/local/include/DBoW2/BowVector.h:14:
/usr/include/c++/v1/map:837:5: error: static_assert failed
"Allocator::value_type must be same type as value_type"
static_assert((is_same<typename allocator_type::value_type,
value_type>::value),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:436:21:
note: in instantiation of template class
'std::__1::map<ORB_SLAM2::KeyFrame *, g2o::Sim3,
std::__1::less<ORB_SLAM2::KeyFrame *>,
Eigen::aligned_allocator<std::__1::pair<const ORB_SLAM2::KeyFrame *,
g2o::Sim3> > >' requested here
KeyFrameAndPose CorrectedSim3, NonCorrectedSim3;
^
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:466:29:
error: no viable overloaded operator[] for type 'KeyFrameAndPose' (aka
'map<ORB_SLAM2::KeyFrame *, g2o::Sim3, std::less<KeyFrame *>,
Eigen::aligned_allocator<std::pair<const KeyFrame *, g2o::Sim3> > >')
NonCorrectedSim3[pKFi]=g2oSiw;
~~~~~~~~~~~~~~~~^~~~~
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:470:39:
error: use of undeclared identifier 'mit'; did you mean 'min'?
for(KeyFrameAndPose::iterator mit=CorrectedSim3.begin(),
mend=CorrectedSim3.end(); mit!=mend; mit++)
^~~
min
/usr/include/c++/v1/algorithm:2562:1: note: 'min' declared here
min(const _Tp& __a, const _Tp& __b, _Compare __comp)

Dimitry Andric

unread,
Jun 15, 2016, 5:55:00 AM6/15/16
to Otacílio, freebsd...@freebsd.org
On 15 Jun 2016, at 03:40, Otacílio <otacil...@bsd.com.br> wrote:
>
> Em 14/06/2016 18:14, Dimitry Andric escreveu:
>> On 14 Jun 2016, at 06:05, Otacílio <otacil...@bsd.com.br> wrote:
>>> I'm getting this error when I try compile the ORB-SLAM2 library. Some one can give me a hint about it?
>>>
>>>
>>> /usr/include/c++/v1/map:837:5: error: static_assert failed "Allocator::value_type must be same type as value_type"
>>> static_assert((is_same<typename allocator_type::value_type, value_type>::value),
>> Typically, this is because the allocator for std::map must use a const
>> key, and libc++ now checks for this with a static assertion.
>>
>> See for example this fix for www/node:
>> https://svnweb.freebsd.org/ports/head/www/node/files/patch-deps_v8_src_compiler_instruction.h?view=markup&pathrev=412412
>>
>> -Dimitry
>>
> I think that this problem is more difficult that the example. Bellow is the error message:
>
> In file included from /usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:21:
> In file included from /usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/LoopClosing.h:24:
> In file included from /usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/KeyFrame.h:24:
> In file included from /usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/MapPoint.h:25:
> In file included from /usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/Frame.h:27:
> In file included from /usr/local/include/DBoW2/BowVector.h:14:
> /usr/include/c++/v1/map:837:5: error: static_assert failed "Allocator::value_type must be same type as value_type"
> static_assert((is_same<typename allocator_type::value_type, value_type>::value),
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:436:21: note: in instantiation of template class 'std::__1::map<ORB_SLAM2::KeyFrame *, g2o::Sim3, std::__1::less<ORB_SLAM2::KeyFrame *>, Eigen::aligned_allocator<std::__1::pair<const ORB_SLAM2::KeyFrame *, g2o::Sim3> > >' requested here
> KeyFrameAndPose CorrectedSim3, NonCorrectedSim3;

This patch should hopefully work. I do not have the port itself, so I could not compile-test it.

diff --git a/include/LoopClosing.h b/include/LoopClosing.h
index b1736fe..5d80d02 100644
--- a/include/LoopClosing.h
+++ b/include/LoopClosing.h
@@ -47,7 +47,7 @@ public:

typedef pair<set<KeyFrame*>,int> ConsistentGroup;
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
- Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
+ Eigen::aligned_allocator<std::pair<KeyFrame const*, g2o::Sim3> > > KeyFrameAndPose;

public:

-Dimitry

signature.asc

Otacílio

unread,
Jun 15, 2016, 7:31:53 AM6/15/16
to freebsd...@freebsd.org
Dear

I have applied your patch, but the bug stay there :(

In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:21:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/LoopClosing.h:24:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/KeyFrame.h:24:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/MapPoint.h:25:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/Frame.h:27:
In file included from /usr/local/include/DBoW2/BowVector.h:14:
/usr/include/c++/v1/map:837:5: error: static_assert failed
"Allocator::value_type must be same type as value_type"
static_assert((is_same<typename allocator_type::value_type,
value_type>::value),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:436:21:
note: in instantiation of template class
'std::__1::map<ORB_SLAM2::KeyFrame *, g2o::Sim3,
std::__1::less<ORB_SLAM2::KeyFrame *>,
Eigen::aligned_allocator<std::__1::pair<const ORB_SLAM2::KeyFrame *,
g2o::Sim3> > >' requested here
KeyFrameAndPose CorrectedSim3, NonCorrectedSim3;


This is the source code of LoopClosing.h after patch:

#ifndef LOOPCLOSING_H
#define LOOPCLOSING_H

#include "KeyFrame.h"
#include "LocalMapping.h"
#include "Map.h"
#include "ORBVocabulary.h"
#include "Tracking.h"

#include "KeyFrameDatabase.h"

#include <thread>
#include <mutex>
#include <g2o/types/sim3/types_seven_dof_expmap.h>

namespace ORB_SLAM2
{

class Tracking;
class LocalMapping;
class KeyFrameDatabase;


class LoopClosing
{
public:

typedef pair<set<KeyFrame*>,int> ConsistentGroup;
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
Eigen::aligned_allocator<std::pair<KeyFrame const*, g2o::Sim3>
> > KeyFrameAndPose;


Otacílio

unread,
Jun 15, 2016, 7:32:28 AM6/15/16
to Dimitry Andric, freebsd...@freebsd.org
Em 15/06/2016 06:54, Dimitry Andric escreveu:
Dear

I have applied your patch, but the bug stay there :(

In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:21:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/LoopClosing.h:24:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/KeyFrame.h:24:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/MapPoint.h:25:
In file included from
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/include/Frame.h:27:
In file included from /usr/local/include/DBoW2/BowVector.h:14:
/usr/include/c++/v1/map:837:5: error: static_assert failed
"Allocator::value_type must be same type as value_type"
static_assert((is_same<typename allocator_type::value_type,
value_type>::value),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/graphics/orbslam2/work/ORB_SLAM2-132d92f/src/LoopClosing.cc:436:21:
note: in instantiation of template class
'std::__1::map<ORB_SLAM2::KeyFrame *, g2o::Sim3,
std::__1::less<ORB_SLAM2::KeyFrame *>,
Eigen::aligned_allocator<std::__1::pair<const ORB_SLAM2::KeyFrame *,
g2o::Sim3> > >' requested here
KeyFrameAndPose CorrectedSim3, NonCorrectedSim3;


This is the source code of LoopClosing.h after patch:

#ifndef LOOPCLOSING_H
#define LOOPCLOSING_H

#include "KeyFrame.h"
#include "LocalMapping.h"
#include "Map.h"
#include "ORBVocabulary.h"
#include "Tracking.h"

#include "KeyFrameDatabase.h"

#include <thread>
#include <mutex>
#include <g2o/types/sim3/types_seven_dof_expmap.h>

namespace ORB_SLAM2
{

class Tracking;
class LocalMapping;
class KeyFrameDatabase;


class LoopClosing
{
public:

typedef pair<set<KeyFrame*>,int> ConsistentGroup;
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
Eigen::aligned_allocator<std::pair<KeyFrame const*, g2o::Sim3>
> > KeyFrameAndPose;

Ed Schouten

unread,
Jun 15, 2016, 7:37:34 AM6/15/16
to Dimitry Andric, freebsd...@freebsd.org, Otacílio
2016-06-15 11:54 GMT+02:00 Dimitry Andric <d...@freebsd.org>:
> - Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
> + Eigen::aligned_allocator<std::pair<KeyFrame const*, g2o::Sim3> > > KeyFrameAndPose;

Looking at the patch for Node, a const keyword should be added to the
type itself, right?

Eigen::aligned_allocator<std::pair<const KeyFrame * const, g2o::Sim3>
> > KeyFrameAndPose;

--
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717

Otacílio

unread,
Jun 15, 2016, 7:42:40 AM6/15/16
to Ed Schouten, freebsd...@freebsd.org
Em 15/06/2016 08:37, Ed Schouten escreveu:
> 2016-06-15 11:54 GMT+02:00 Dimitry Andric <d...@freebsd.org>:
>> - Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
>> + Eigen::aligned_allocator<std::pair<KeyFrame const*, g2o::Sim3> > > KeyFrameAndPose;
> Looking at the patch for Node, a const keyword should be added to the
> type itself, right?
>
> Eigen::aligned_allocator<std::pair<const KeyFrame * const, g2o::Sim3>
>>> KeyFrameAndPose;

No, I have tested with

Eigen::aligned_allocator<std::pair<KeyFrame const*, g2o::Sim3> > > KeyFrameAndPose;

and

Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;

And nothing works. :(

[]'s
-Otacílio

Otacílio

unread,
Jun 15, 2016, 7:48:51 AM6/15/16
to Dimitry Andric, freebsd...@freebsd.org
Em 15/06/2016 06:54, Dimitry Andric escreveu:
I have try this line bellow and it works (!!!) :0

Eigen::aligned_allocator<std::pair<KeyFrame *const, g2o::Sim3> > >
KeyFrameAndPose;


[]'s

-Otacílio

Joerg Sonnenberger

unread,
Jun 15, 2016, 9:21:22 AM6/15/16
to freebsd...@freebsd.org
On Wed, Jun 15, 2016 at 11:54:17AM +0200, Dimitry Andric wrote:
> This patch should hopefully work. I do not have the port itself, so I could not compile-test it.
>
> diff --git a/include/LoopClosing.h b/include/LoopClosing.h
> index b1736fe..5d80d02 100644
> --- a/include/LoopClosing.h
> +++ b/include/LoopClosing.h
> @@ -47,7 +47,7 @@ public:
>
> typedef pair<set<KeyFrame*>,int> ConsistentGroup;
> typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
> - Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
> + Eigen::aligned_allocator<std::pair<KeyFrame const*, g2o::Sim3> > > KeyFrameAndPose;

That's a stylistic change only:
const foo * == foo const * != foo * const.

Joerg

Dimitry Andric

unread,
Jun 15, 2016, 12:53:05 PM6/15/16
to Joerg Sonnenberger, freebsd...@freebsd.org
On 15 Jun 2016, at 15:20, Joerg Sonnenberger <jo...@bec.de> wrote:
>
> On Wed, Jun 15, 2016 at 11:54:17AM +0200, Dimitry Andric wrote:
>> This patch should hopefully work. I do not have the port itself, so I could not compile-test it.
>>
>> diff --git a/include/LoopClosing.h b/include/LoopClosing.h
>> index b1736fe..5d80d02 100644
>> --- a/include/LoopClosing.h
>> +++ b/include/LoopClosing.h
>> @@ -47,7 +47,7 @@ public:
>>
>> typedef pair<set<KeyFrame*>,int> ConsistentGroup;
>> typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
>> - Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
>> + Eigen::aligned_allocator<std::pair<KeyFrame const*, g2o::Sim3> > > KeyFrameAndPose;
>
> That's a stylistic change only:
> const foo * == foo const * != foo * const.

Yeah sorry, I realized that only after sending, it should indeed be
"KeyFrame* const", e.g the pointer itself (which is the key to for
std::map<>) should be const, not the thing pointed to.

-Dimitry

signature.asc

jef1...@gmail.com

unread,
Nov 29, 2017, 9:12:01 AM11/29/17
to
在 2016年6月15日星期三 UTC+8下午7:48:51,Otacílio写道:
Thanks very much! It works for me
0 new messages