Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

static linking question

Started by indigox3 1 reply 400+ views
Original Post
indigox3
indigox3
Hi, I'm using VS.NET to create a static library, 3dLib.lib. This library links to a static math library, MathLib1.lib. I have tried creating a simple console app and linking it to MathLib1.lib in order to test the library. The app works great. However, when I try linking MathLib1.lib to 3dLib.lib I get tons of errors about multiple definitions, similar to: MathLib1.lib(Color.obj) : warning LNK4006: "public: void __thiscall Color::ClampTo01(void)" (?ClampTo01@Color@@QAEXXZ) already defined in MathLib1.lib(Color.obj); second definition ignored My code for 3dLib looks like: dummy.h: #include "../MathLib1/Maths.h" class Dummy { public: Dummy(); ~Dummy(); int x; }; dummy.cpp: #include "dummy.h" Dummy::Dummy() { Vector3 s; //Vector3 is defined in MathLib1.lib s.Set(2,2,2); } Dummy::~Dummy() { } Under Project Properties > Librarian > Additional Dependencies I am specifying MathLib1.lib. Oddly enough, if I remove MathLib1.lib from the dependencies, everything compiles fine. How is possble that the above code compiles, when I don't link with Mathlib1.lib? I would expect the compiler to complain about not having the definition of Vector3::Set( ... ) without linking to the MathLib.
PnP Bios
PnP Bios
you are forgeting inclusion guards it looks like.

#ifndef __MATH_3D__
#define __MATH_3D__

--code--


#endif
indigox3
indigox3
No, I have them in all of my header files, thanks for the advice though.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.