[SOLVED]MinGW refuses to compile ColDet!

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
ChrML
Posts: 30
Joined: Sun Oct 03, 2004 2:45 pm
Location: Norway

[SOLVED]MinGW refuses to compile ColDet!

Post by ChrML »

I've got a slight problem when using ColDet. It says that it is compatible with any ISO C++ compatible compiler, but MinGW returns this error when I run it's makefile to compile the library:
MAKE Version 5.2 Copyright (c) 1987, 1998 Inprise Corp.
g++ -c -O2 -DGCC coldet.cpp
In file included from coldet.cpp:25: coldetimpl.h: In member function `int CollisionModel3DImpl::getTriangleIndex(BoxedTriangle*)':

coldetimpl.h:76: error: no match for 'operator-' in 'bt - (((std::vector<BoxedTriangle, std::allocator<BoxedTriangle> >*)((CollisionModel3DImpl*)this)) + 4u)->std::vector<_Tp, _Alloc>::begin [with _Tp = BoxedTriangle, _Alloc = std::allocator<BoxedTriangle>]()'

math3d.h:174: note: candidates are: Vector3D operator-(const Vector3D&, const Vector3D&)

F:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_bvector.h:180: note: ptrdiff_t std::operator-(const std::_Bit_iterator_base&, const std::_Bit_iterator_base&)

In file included from coldet.cpp:26:
mytritri.h:96:21: warning: no newline at end of file

** error 1 ** deleting coldet.o

The first thing I tried was copying it's source to a \coldet sub directory under the source for my game, and include it's header, but then DevC++ (with it's MinGW compiler) returns the same error. I don't know a lot about C++ template classes (haven't needed them yet), but this code in the library seems to give the error:

Code: Select all

int getTriangleIndex(BoxedTriangle* bt)
{
    return int(bt-m_Triangles.begin());  // <<<<
}
I rewrote the line to:

Code: Select all

int getTriangleIndex(BoxedTriangle* bt)
{
    (std::vector<BoxedTriangle>::iterator)bt - m_Triangles.begin();
}
I don't know if that makes it the same, but it compiles, and doesn't even run that far before it crashes (tested with MessageBoxes). Actually it doesn't even enter the collision() function (the crash happens between the call to colmodel->collision(othermodel) and the start of CollisionModel3DImpl::collision(). Any ideas? I guess some more people has got ColDet working. In the meantime while waiting for replies, I'll make a test program to check this out.
ChrML
Posts: 30
Joined: Sun Oct 03, 2004 2:45 pm
Location: Norway

Post by ChrML »

Got it working :). I exchanged the line with

return int(bt-&(*(m_Triangles.begin())));

Then it compiled nicely. About the other error, stupid me had forgot returning the pointer to the CollisionModel3D instance I created in a function.
Post Reply