我正在尝试为 OBS 创建一个 DLL 插件,但是当我尝试编译一个简单的脚本时,它给了我以下错误 -
Error 1 error LNK2005: _DllMain@12 already defined in dllmain.obj c:\Users\user\documents\visual studio 2013\Projects\name\nameEnhanced\nameEnhanced.obj nameEnhanced
和
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
我创建了一个简单的脚本,它只有 2 个文件,即 -
handle.h
nameEnhanced.cpp
这些是我的文件-
句柄.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);
}
};
}
和
名称增强.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
}
我试图删除该dllmain.obj
文件,但没有奏效
我使用https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx作为我的代码的基础