-1
我試圖創建OBS一個DLL插件,但是當我嘗試編譯一個簡單的腳本,它給了我下面的錯誤 -錯誤LNK 2005和LNK1169 C++的Visual Studio DLL
Error 1 error LNK2005: [email protected] 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
這些都是我的文件 -
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);
}
};
}
和
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
}
我試圖刪除dllmain.obj
文件,但沒有奏效
我已使用https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx作爲我的代碼的基礎
我對使用Visual Studio不是很熟悉。 – Gerwin
所以你需要我告訴你如何從項目中刪除源文件?這不會發生。 – trojanfoe
好吧,那個工作,我從來沒有要求你告訴我如何刪除一個文件,我只是認爲你的意思是別的,不需要攻擊人。 – Gerwin