Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#Actualharshman_chris

Posted 17 January 2013 - 03:51 PM

So this is the error I am getting when using part of dll. There is quite a bit of code involved in this one.

 

 

I know this is a messy error mesage, sorry.

Error	175	error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall ParticlesEngine::Event<class ParticlesEngine::EventData>::operator+=(class ParticlesEngine::Delegate<class ParticlesEngine::EventData> *)" (__imp_??Y?$Event@VEventData@ParticlesEngine@@@ParticlesEngine@@QAEXPAV?$Delegate@VEventData@ParticlesEngine@@@1@@Z) referenced in function "public: virtual void __thiscall TestScene::initialize(void)" (?initialize@TestScene@@UAEXXZ)	C:\Users\100312531\Desktop\Project-Seventeen\ParticleEngineProject\EngineTest\TestScene.obj	EngineTest

 

Here is all the code segements, if I am missing anything, or I need to answer a question let me know.


//TestScene.h #include <Delegate.h> #include <EventData.h> #include <Event.h> class TestScene : Scene { void OnButtonClick(EventData data); void OnButtonEnter(EventData data); void OnButtonLeave(EventData data); EventHandler(TestScene, OnButtonClick, EventData); EventHandler(TestScene, OnButtonEnter, EventData); EventHandler(TestScene, OnButtonLeave, EventData);

}

//TestScene.cpp

void TestScene::initialize()
{
button->OnClick += &EOnButtonClick;
button->OnEnter += &EOnButtonEnter;
button->OnLeave += &EOnButtonLeave;
}

void TestScene::OnButtonClick(EventData data)
{
}

void TestScene::OnButtonEnter(EventData data)
{
}

void TestScene::OnButtonLeave(EventData data)
{
}

 

 

The Code from the dll, the custom event system I am using, it is pretty straight forward.

#ifndef _EVENT_H
#define _EVENT_H

#include <vector>
#include <algorithm>
#include "Delegate.h"

#ifdef PARTICLESENGINE_DLL 
#define PARTICLESENGINE_API __declspec( dllexport )
#else
#define PARTICLESENGINE_API __declspec( dllimport )
#endif

namespace ParticlesEngine
{

	template <typename T>
	class PARTICLESENGINE_API Event
	{
		public:
			inline void operator+=(Delegate<T>* delegate)
			{
				// An object can only subscribe once
				if (find(_delegates.begin(), _delegates.end(), delegate) == _delegates.end())
				{
					_delegates.push_back(delegate);
				}
			}

			inline void operator-=(Delegate<T>* delegate)
			{
				typedef typename std::vector< Delegate<T>* >::iterator iter;
				iter i = _delegates.begin();
				while (i != _delegates.end())
				{
					if (*i == delegate)
					{
						i = _delegates.erase(i);
					}
					else
					{
						++i;
					}
				}
			}

			inline void operator()(T param)
			{
				typedef typename std::vector< Delegate<T>* >::iterator iter;
				for (iter i = _delegates.begin(); i != _delegates.end(); ++i)
				{
					(*i)->operator()(param);
				}
			}

		private:
			std::vector< Delegate<T>* > _delegates;
	};

}

#endif
#ifndef _EVENTDATA_H
#define _EVENTDATA_H

#ifdef PARTICLESENGINE_DLL 
#define PARTICLESENGINE_API __declspec( dllexport )
#else
#define PARTICLESENGINE_API __declspec( dllimport )
#endif

namespace ParticlesEngine
{

	class EventData
	{
	public:
		PARTICLESENGINE_API EventData()
		{
		}
	};

}

#endif
#ifndef _DELEGATE_H
#define _DELEGATE_H

#ifdef PARTICLESENGINE_DLL 
#define PARTICLESENGINE_API __declspec( dllexport )
#else
#define PARTICLESENGINE_API __declspec( dllimport )
#endif

namespace ParticlesEngine
{

	#define EventHandler(thisType, handler, type)\
		class __E##handler##__ : public Delegate< type >\
		{\
			public:\
				__E##handler##__ ( thisType * obj )\
				: _obj(obj) {}\
				inline void operator()( type param )\
				{\
					_obj-> handler (param);\
				}\
				thisType * _obj;\
		};\
		__E##handler##__ E##handler;

	template <typename T>
	class PARTICLESENGINE_API Delegate
	{
	public:
		virtual void operator()(T param) = 0;
	};

}

#endif

#1harshman_chris

Posted 17 January 2013 - 03:49 PM

So this is the error I am getting when using part of dll. There is quite a bit of code involved in this one.

 

 

I know this is a messy error mesage, sorry.

Error	175	error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall ParticlesEngine::Event<class ParticlesEngine::EventData>::operator+=(class ParticlesEngine::Delegate<class ParticlesEngine::EventData> *)" (__imp_??Y?$Event@VEventData@ParticlesEngine@@@ParticlesEngine@@QAEXPAV?$Delegate@VEventData@ParticlesEngine@@@1@@Z) referenced in function "public: virtual void __thiscall TestScene::initialize(void)" (?initialize@TestScene@@UAEXXZ)	C:\Users\100312531\Desktop\Project-Seventeen\ParticleEngineProject\EngineTest\TestScene.obj	EngineTest

 

Here is all the code segements, if I am missing anything, or I need to answer a question let me know.


 

//TestScene.h
#include <Delegate.h>
#include <EventData.h>
#include <Event.h>

class TestScene : Scene
{

void OnButtonClick(EventData data);
void OnButtonEnter(EventData data);
void OnButtonLeave(EventData data);

EventHandler(TestScene, OnButtonClick, EventData);
EventHandler(TestScene, OnButtonEnter, EventData);
EventHandler(TestScene, OnButtonLeave, EventData);

}

 

//TestScene.cpp

void TestScene::initialize()
{
button->OnClick += &EOnButtonClick;
button->OnEnter += &EOnButtonEnter;
button->OnLeave += &EOnButtonLeave;
}

void TestScene::OnButtonClick(EventData data)
{
}

void TestScene::OnButtonEnter(EventData data)
{
}

void TestScene::OnButtonLeave(EventData data)
{
}

 

 

The Code from the dll, the custom event system I am using, it is pretty straight forward.

#ifndef _EVENT_H
#define _EVENT_H

#include <vector>
#include <algorithm>
#include "Delegate.h"

#ifdef PARTICLESENGINE_DLL 
#define PARTICLESENGINE_API __declspec( dllexport )
#else
#define PARTICLESENGINE_API __declspec( dllimport )
#endif

namespace ParticlesEngine
{

	template <typename T>
	class PARTICLESENGINE_API Event
	{
		public:
			inline void operator+=(Delegate<T>* delegate)
			{
				// An object can only subscribe once
				if (find(_delegates.begin(), _delegates.end(), delegate) == _delegates.end())
				{
					_delegates.push_back(delegate);
				}
			}

			inline void operator-=(Delegate<T>* delegate)
			{
				typedef typename std::vector< Delegate<T>* >::iterator iter;
				iter i = _delegates.begin();
				while (i != _delegates.end())
				{
					if (*i == delegate)
					{
						i = _delegates.erase(i);
					}
					else
					{
						++i;
					}
				}
			}

			inline void operator()(T param)
			{
				typedef typename std::vector< Delegate<T>* >::iterator iter;
				for (iter i = _delegates.begin(); i != _delegates.end(); ++i)
				{
					(*i)->operator()(param);
				}
			}

		private:
			std::vector< Delegate<T>* > _delegates;
	};

}

#endif
#ifndef _EVENTDATA_H
#define _EVENTDATA_H

#ifdef PARTICLESENGINE_DLL 
#define PARTICLESENGINE_API __declspec( dllexport )
#else
#define PARTICLESENGINE_API __declspec( dllimport )
#endif

namespace ParticlesEngine
{

	class EventData
	{
	public:
		PARTICLESENGINE_API EventData()
		{
		}
	};

}

#endif
#ifndef _DELEGATE_H
#define _DELEGATE_H

#ifdef PARTICLESENGINE_DLL 
#define PARTICLESENGINE_API __declspec( dllexport )
#else
#define PARTICLESENGINE_API __declspec( dllimport )
#endif

namespace ParticlesEngine
{

	#define EventHandler(thisType, handler, type)\
		class __E##handler##__ : public Delegate< type >\
		{\
			public:\
				__E##handler##__ ( thisType * obj )\
				: _obj(obj) {}\
				inline void operator()( type param )\
				{\
					_obj-> handler (param);\
				}\
				thisType * _obj;\
		};\
		__E##handler##__ E##handler;

	template <typename T>
	class PARTICLESENGINE_API Delegate
	{
	public:
		virtual void operator()(T param) = 0;
	};

}

#endif

 

 


PARTNERS