From 147a4119cbdf8532ed61608a62d9536eca202f77 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sun, 13 Jul 2014 21:54:07 +0200 Subject: [PATCH] Fix linker problem This fixes the linker problem: /usr/bin/ld: error: ../../libraries/shared/libshared.a(StreamUtils.cpp.o): multiple definition of 'operator<<(std::ostream&, glm::detail::tvec3 const&)' /usr/bin/ld: CMakeFiles/physics-tests.dir/src/PhysicsTestUtil.cpp.o: previous definition here /usr/bin/ld: error: ../../libraries/shared/libshared.a(StreamUtils.cpp.o): multiple definition of 'operator<<(std::ostream&, glm::detail::tquat const&)' /usr/bin/ld: CMakeFiles/physics-tests.dir/src/PhysicsTestUtil.cpp.o: previous definition here /usr/bin/ld: error: ../../libraries/shared/libshared.a(StreamUtils.cpp.o): multiple definition of 'operator<<(std::ostream&, glm::detail::tmat4x4 const&)' /usr/bin/ld: CMakeFiles/physics-tests.dir/src/PhysicsTestUtil.cpp.o: previous definition here collect2: error: ld returned 1 exit status Note these are the serializers to std::ostream that were already there, not the ones that I added (which are to QDebug). This bug was already there, I only got these errors now after adding some debug code. The reason is obvious: they are already defined in libshared.a (through StreamUtils.cpp). No need to define them again in ./tests/physics/src/PhysicsTestUtil.cpp --- tests/physics/src/PhysicsTestUtil.cpp | 20 +------------------- tests/physics/src/PhysicsTestUtil.h | 3 --- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/tests/physics/src/PhysicsTestUtil.cpp b/tests/physics/src/PhysicsTestUtil.cpp index f176d5e637..a11d4f2add 100644 --- a/tests/physics/src/PhysicsTestUtil.cpp +++ b/tests/physics/src/PhysicsTestUtil.cpp @@ -12,25 +12,7 @@ #include #include "PhysicsTestUtil.h" - -std::ostream& operator<<(std::ostream& s, const glm::vec3& v) { - s << "<" << v.x << "," << v.y << "," << v.z << ">"; - return s; -} - -std::ostream& operator<<(std::ostream& s, const glm::quat& q) { - s << "<" << q.x << "," << q.y << "," << q.z << "," << q.w << ">"; - return s; -} - -std::ostream& operator<<(std::ostream& s, const glm::mat4& m) { - s << "["; - for (int j = 0; j < 4; ++j) { - s << " " << m[0][j] << " " << m[1][j] << " " << m[2][j] << " " << m[3][j] << ";"; - } - s << " ]"; - return s; -} +#include "StreamUtils.h" std::ostream& operator<<(std::ostream& s, const CollisionInfo& c) { s << "[penetration=" << c._penetration diff --git a/tests/physics/src/PhysicsTestUtil.h b/tests/physics/src/PhysicsTestUtil.h index 998a18ff5d..c93545dd76 100644 --- a/tests/physics/src/PhysicsTestUtil.h +++ b/tests/physics/src/PhysicsTestUtil.h @@ -21,9 +21,6 @@ const glm::vec3 xAxis(1.f, 0.f, 0.f); const glm::vec3 yAxis(0.f, 1.f, 0.f); const glm::vec3 zAxis(0.f, 0.f, 1.f); -std::ostream& operator<<(std::ostream& s, const glm::vec3& v); -std::ostream& operator<<(std::ostream& s, const glm::quat& q); -std::ostream& operator<<(std::ostream& s, const glm::mat4& m); std::ostream& operator<<(std::ostream& s, const CollisionInfo& c); #endif // hifi_PhysicsTestUtil_h