私はデータベースに接続するためにC++で*dllを書いています。コンソールアプリケーションでafxdb.hを使用してみましたが、正常に動作します。ここで、*dllで同じコードを使用したいと思います。そこで、stdafx.hにafxdb.hを追加しましたが、コンパイルするとこのエラーが発生しました
mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in JunkDLL.obj
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in JunkDLL.obj; second definition ignored
Creating library Debug/JunkDLL.lib and object Debug/JunkDLL.exp
Debug/JunkDLL.dll : fatal error LNK1169: one or more multiply defined symbols found
私のstdafx.hは次のようになります
#if !defined(AFX_STDAFX_H__123__INCLUDED_)
#define AFX_STDAFX_H__123__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "afxwin.h"
#include "afxext.h"
#include "afxdb.h"
// Insert your headers here
#define WIN32_LEAN_AND_MEAN// Exclude rarely-used stuff from Windows headers
#include "windows.h"
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__123__INCLUDED_)
助けてくれてありがとう。