I'm trying to create a DLL plugin for OBS, but when I try to compile a simple script it gives me the following errors -
Error 1 error LNK2005: _DllMain@12 already defined in dllmain.obj c:\Users\user\documents\visual studio 2013\Projects\name\nameEnhanced\nameEnhanced.obj nameEnhanced
and
Error 2 error LNK1169: one or more multiply defined symbols found c:\users\user\documents\visual studio 2013\Projects\name\Debug\nameEnhanced.dll 1 1 nameEnhanced
I've created a simple script, which only has 2 files namely -
handle.h
nameEnhanced.cpp
these are my files -
handle.h
#include <windows.h>
#include <string>
using namespace std;
namespace MsgeBox
{
class myMessage
{
public:
static void createMessage(HWND windowsOwner, LPCWSTR theMessage, LPCWSTR theTitle, UINT theIcon){
MessageBox(windowsOwner, theMessage, theTitle, theIcon);
}
};
}
and
nameEnhanced.cpp
// nameEnhanced.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include <Windows.h>
#include "handle.h"
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
MsgeBox::myMessage::createMessage(NULL, (LPCWSTR)"Hello", (LPCWSTR)"I See You.", MB_ICONWARNING | MB_CANCELTRYCONTINUE);
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // successful
}
I've tried to delete the dllmain.obj
file but that didn't work
I've used https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx as a base for my code