我目前正在尝试使用reactphysics3d库来制作简单的粒子碰撞模拟器。 https://www.reactphysics3d.com/
我试图用静态库编译我的c ++文件,但是编译不好。目录结构是这样的。
ParticleSimulation
|
|-- test.cpp
|
|-- lib
| |-- libreactphysics3d.a
|
|-- reactphysics3d
| |-- src
| |-- reactphysics3d.h
我的测试代码是
#include "reactphysics3d.h"
using namespace reactphysics3d;
int main() {
rp3d::SphereShape * sphereShape = new SphereShape(1.0);
delete sphereShape;
}
我尝试用
进行编译gcc -std=c++11 -Ireactphysics3d/src -Llib -lreactphysics3d -o myapp test.cpp ./lib/libreactphysics3d.a
整个错误消息太长,无法在此处发布(超过30000个字符超出了Stackoverflow的单个帖子的限制)。消息的第一行是
Undefined symbols for architecture x86_64:
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::str() const in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
reactphysics3d::ConcaveMeshShape::to_string() const in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"std::__1::ios_base::getloc() const", referenced from:
reactphysics3d::ConcaveMeshShape::to_string() const in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"std::runtime_error::runtime_error(char const*)", referenced from:
reactphysics3d::HalfEdgeStructure::init() in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
...
"std::runtime_error::~runtime_error()", referenced from:
reactphysics3d::HalfEdgeStructure::init() in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
...
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string<std::nullptr_t>(char const*) in test-db2b03.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, char const*) in test-db2b03.o
reactphysics3d::FixedJoint::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
reactphysics3d::Vector3::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
reactphysics3d::Quaternion::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
reactphysics3d::HingeJoint::to_string() const in libreactphysics3d.a(HingeJoint.cpp.o)
reactphysics3d::Vector3::to_string() const in libreactphysics3d.a(HingeJoint.cpp.o)
reactphysics3d::Quaternion::to_string() const in libreactphysics3d.a(HingeJoint.cpp.o)
...
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in test-db2b03.o
reactphysics3d::FixedJoint::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
reactphysics3d::Vector3::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
reactphysics3d::Quaternion::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
reactphysics3d::HingeJoint::to_string() const in libreactphysics3d.a(HingeJoint.cpp.o)
reactphysics3d::Vector3::to_string() const in libreactphysics3d.a(HingeJoint.cpp.o)
reactphysics3d::Quaternion::to_string() const in libreactphysics3d.a(HingeJoint.cpp.o)
...
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::insert(unsigned long, char const*)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) in test-db2b03.o
reactphysics3d::FixedJoint::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
reactphysics3d::Vector3::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
reactphysics3d::Quaternion::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
reactphysics3d::HingeJoint::to_string() const in libreactphysics3d.a(HingeJoint.cpp.o)
reactphysics3d::Vector3::to_string() const in libreactphysics3d.a(HingeJoint.cpp.o)
reactphysics3d::Quaternion::to_string() const in libreactphysics3d.a(HingeJoint.cpp.o)
...
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::resize(unsigned long, char)", referenced from:
std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::overflow(int) in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
最后一行是
non-virtual thunk to std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_stringstream() in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
virtual thunk to std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_stringstream() in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_stringstream() in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
non-virtual thunk to std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_stringstream() in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
virtual thunk to std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_stringstream() in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
...
"std::__1::to_string(float)", referenced from:
reactphysics3d::SphereShape::to_string() const in test-db2b03.o
reactphysics3d::CapsuleShape::to_string() const in test-db2b03.o
reactphysics3d::SliderJoint::to_string() const in test-db2b03.o
reactphysics3d::HingeJoint::to_string() const in test-db2b03.o
reactphysics3d::Vector3::to_string() const in test-db2b03.o
reactphysics3d::Quaternion::to_string() const in test-db2b03.o
reactphysics3d::Vector3::to_string() const in libreactphysics3d.a(FixedJoint.cpp.o)
...
"std::terminate()", referenced from:
___clang_call_terminate in test-db2b03.o
___clang_call_terminate in libreactphysics3d.a(TriangleShape.cpp.o)
___clang_call_terminate in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
___clang_call_terminate in libreactphysics3d.a(BoxShape.cpp.o)
___clang_call_terminate in libreactphysics3d.a(DynamicAABBTree.cpp.o)
___clang_call_terminate in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
___clang_call_terminate in libreactphysics3d.a(mathematics_functions.cpp.o)
...
"typeinfo for std::__1::basic_istream<char, std::__1::char_traits<char> >", referenced from:
construction vtable for std::__1::basic_istream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"typeinfo for std::__1::basic_ostream<char, std::__1::char_traits<char> >", referenced from:
construction vtable for std::__1::basic_ostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"typeinfo for std::__1::basic_iostream<char, std::__1::char_traits<char> >", referenced from:
construction vtable for std::__1::basic_iostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
typeinfo for std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"typeinfo for std::__1::basic_streambuf<char, std::__1::char_traits<char> >", referenced from:
typeinfo for std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"typeinfo for std::runtime_error", referenced from:
reactphysics3d::HalfEdgeStructure::init() in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
...
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for reactphysics3d::DynamicAABBTreeOverlapCallback in test-db2b03.o
typeinfo for reactphysics3d::Joint in test-db2b03.o
typeinfo for reactphysics3d::Joint in libreactphysics3d.a(FixedJoint.cpp.o)
typeinfo for reactphysics3d::Joint in libreactphysics3d.a(HingeJoint.cpp.o)
typeinfo for reactphysics3d::Joint in libreactphysics3d.a(SliderJoint.cpp.o)
typeinfo for reactphysics3d::Joint in libreactphysics3d.a(BallAndSocketJoint.cpp.o)
typeinfo for reactphysics3d::CollisionShape in libreactphysics3d.a(CollisionShape.cpp.o)
...
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__si_class_type_info", referenced from:
typeinfo for reactphysics3d::ConvexShape in test-db2b03.o
typeinfo for reactphysics3d::ConvexPolyhedronShape in test-db2b03.o
typeinfo for reactphysics3d::BoxShape in test-db2b03.o
typeinfo for reactphysics3d::SphereShape in test-db2b03.o
typeinfo for reactphysics3d::CapsuleShape in test-db2b03.o
typeinfo for reactphysics3d::TriangleShape in test-db2b03.o
typeinfo for reactphysics3d::ConcaveShape in test-db2b03.o
...
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"non-virtual thunk to std::__1::basic_iostream<char, std::__1::char_traits<char> >::~basic_iostream()", referenced from:
construction vtable for std::__1::basic_iostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"non-virtual thunk to std::__1::basic_iostream<char, std::__1::char_traits<char> >::~basic_iostream()", referenced from:
construction vtable for std::__1::basic_iostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"virtual thunk to std::__1::basic_istream<char, std::__1::char_traits<char> >::~basic_istream()", referenced from:
construction vtable for std::__1::basic_istream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"virtual thunk to std::__1::basic_istream<char, std::__1::char_traits<char> >::~basic_istream()", referenced from:
construction vtable for std::__1::basic_istream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"virtual thunk to std::__1::basic_ostream<char, std::__1::char_traits<char> >::~basic_ostream()", referenced from:
construction vtable for std::__1::basic_ostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"virtual thunk to std::__1::basic_ostream<char, std::__1::char_traits<char> >::~basic_ostream()", referenced from:
construction vtable for std::__1::basic_ostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"virtual thunk to std::__1::basic_iostream<char, std::__1::char_traits<char> >::~basic_iostream()", referenced from:
construction vtable for std::__1::basic_iostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"virtual thunk to std::__1::basic_iostream<char, std::__1::char_traits<char> >::~basic_iostream()", referenced from:
construction vtable for std::__1::basic_iostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"operator delete[](void*)", referenced from:
reactphysics3d::TriangleVertexArray::~TriangleVertexArray() in libreactphysics3d.a(TriangleVertexArray.cpp.o)
reactphysics3d::TriangleVertexArray::~TriangleVertexArray() in libreactphysics3d.a(TriangleVertexArray.cpp.o)
"operator delete(void*)", referenced from:
_main in test-db2b03.o
reactphysics3d::BoxShape::~BoxShape() in test-db2b03.o
reactphysics3d::SphereShape::~SphereShape() in test-db2b03.o
reactphysics3d::CapsuleShape::~CapsuleShape() in test-db2b03.o
reactphysics3d::TriangleShape::~TriangleShape() in test-db2b03.o
reactphysics3d::ConvexTriangleAABBOverlapCallback::~ConvexTriangleAABBOverlapCallback() in test-db2b03.o
reactphysics3d::BallAndSocketJoint::~BallAndSocketJoint() in test-db2b03.o
...
"operator new[](unsigned long)", referenced from:
reactphysics3d::TriangleVertexArray::computeVerticesNormals() in libreactphysics3d.a(TriangleVertexArray.cpp.o)
"operator new(unsigned long)", referenced from:
_main in test-db2b03.o
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::str() const in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
"___cxa_allocate_exception", referenced from:
reactphysics3d::HalfEdgeStructure::init() in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
...
"___cxa_begin_catch", referenced from:
___clang_call_terminate in test-db2b03.o
___clang_call_terminate in libreactphysics3d.a(TriangleShape.cpp.o)
___clang_call_terminate in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::overflow(int) in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
reactphysics3d::HalfEdgeStructure::Face* std::__1::uninitialized_copy<reactphysics3d::HalfEdgeStructure::Face*, reactphysics3d::HalfEdgeStructure::Face*>(reactphysics3d::HalfEdgeStructure::Face*, reactphysics3d::HalfEdgeStructure::Face*, reactphysics3d::HalfEdgeStructure::Face*) in libreactphysics3d.a(BoxShape.cpp.o)
___clang_call_terminate in libreactphysics3d.a(BoxShape.cpp.o)
...
"___cxa_end_catch", referenced from:
std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::overflow(int) in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in libreactphysics3d.a(ConcaveMeshShape.cpp.o)
reactphysics3d::HalfEdgeStructure::Face* std::__1::uninitialized_copy<reactphysics3d::HalfEdgeStructure::Face*, reactphysics3d::HalfEdgeStructure::Face*>(reactphysics3d::HalfEdgeStructure::Face*, reactphysics3d::HalfEdgeStructure::Face*, reactphysics3d::HalfEdgeStructure::Face*) in libreactphysics3d.a(BoxShape.cpp.o)
"___cxa_free_exception", referenced from:
reactphysics3d::HalfEdgeStructure::init() in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
...
"___cxa_pure_virtual", referenced from:
vtable for reactphysics3d::ConvexShape in test-db2b03.o
vtable for reactphysics3d::ConvexPolyhedronShape in test-db2b03.o
vtable for reactphysics3d::ConcaveShape in test-db2b03.o
vtable for reactphysics3d::CollisionShape in libreactphysics3d.a(CollisionShape.cpp.o)
vtable for reactphysics3d::ConvexShape in libreactphysics3d.a(ConvexShape.cpp.o)
vtable for reactphysics3d::ConcaveShape in libreactphysics3d.a(ConcaveShape.cpp.o)
vtable for reactphysics3d::ConvexPolyhedronShape in libreactphysics3d.a(ConvexPolyhedronShape.cpp.o)
...
"___cxa_rethrow", referenced from:
reactphysics3d::HalfEdgeStructure::Face* std::__1::uninitialized_copy<reactphysics3d::HalfEdgeStructure::Face*, reactphysics3d::HalfEdgeStructure::Face*>(reactphysics3d::HalfEdgeStructure::Face*, reactphysics3d::HalfEdgeStructure::Face*, reactphysics3d::HalfEdgeStructure::Face*) in libreactphysics3d.a(BoxShape.cpp.o)
"___cxa_throw", referenced from:
reactphysics3d::HalfEdgeStructure::init() in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::HalfEdgeStructure::Edge> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::add(reactphysics3d::Pair<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int> const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> >::add(reactphysics3d::Pair<unsigned int, reactphysics3d::Pair<unsigned int, unsigned int> > const&, bool) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, unsigned int>::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
reactphysics3d::Map<reactphysics3d::Pair<unsigned int, unsigned int>, reactphysics3d::Pair<unsigned int, unsigned int> >::operator[](reactphysics3d::Pair<unsigned int, unsigned int> const&) in libreactphysics3d.a(HalfEdgeStructure.cpp.o)
...
"___gxx_personality_v0", referenced from:
_main in test-db2b03.o
reactphysics3d::BoxShape::to_string() const in test-db2b03.o
reactphysics3d::SphereShape::to_string() const in test-db2b03.o
reactphysics3d::CapsuleShape::to_string() const in test-db2b03.o
reactphysics3d::TriangleShape::to_string() const in test-db2b03.o
reactphysics3d::BallAndSocketJoint::to_string() const in test-db2b03.o
reactphysics3d::SliderJoint::to_string() const in test-db2b03.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我对使用gcc / g ++编译器编译c / c ++项目感到非常不自在。 您能帮我解决问题吗? 谢谢。
答案 0 :(得分:1)
您的命令行中有两个错误:
gcc -std=c++11 -Ireactphysics3d/src -Llib -lreactphysics3d -o myapp test.cpp ./lib/libreactphysics3d.a
其中一个负责您实际发布的所有未定义的参考链接错误 (尽管可能不负责我们看不到的其他链接错误)。
该错误是您试图使用以下命令链接包含编译的C ++的应用程序:
GCC C前端(gcc
),而不是C ++前端(g++
)。
经过编译的C ++通常会引用标准C ++库中定义的符号。
你是这样做的。因此,您的程序必须与标准C ++库链接。 g++
添加了
标准C库和标准C ++库自动链接。 gcc
仅添加
标准C库。那是两个前端之间的区别。所以你的联系
失败,因为未解析对标准C ++库定义的符号的引用。至
解决此问题,在命令行中将gcc
替换为g++
。
另一个错误-尽管在这种情况下是无害的-命令行:
g++ -std=c++11 -Ireactphysics3d/src -Llib -lreactphysics3d -o myapp test.cpp
将是Your linkage consumes libraries before the object files that refer to them的示例, 这是未定义引用链接失败的另一个常规原因。
库必须以链接顺序出现在 依赖于它们的文件之后。
您的链接不显示其他未定义参考错误的唯一原因
得分是在您的实际命令行中,将-lreactphysics3d
first 放在
链接序列,如果没有任何作用,则可以再次将相同的库添加到链接中
序列,按名称-./lib/libreactphysics3d.a
-之后取决于它的文件,其中
它有效。要摆脱这种冗余,请使用更常规的方法:
g++ -std=c++11 -Ireactphysics3d/src -o myapp test.cpp -Llib -lreactphysics3d
或更不常见:
g++ -std=c++11 -Ireactphysics3d/src -o myapp test.cpp ./lib/libreactphysics3d.a