【发布时间】:2012-12-19 11:22:29
【问题描述】:
我的工作空间中有一个visual c++ 项目,它完全依赖于.lib(静态库)。现在我想使用 Visual c++ 中的现有代码创建一个dll 项目,但它显示我遵循linking 错误:
Linking...
msvcrt.lib(MSVCRT.dll) : error LNK2005: "public: virtual __thiscall exception::~exception(void)" (??1exception@@UAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: "public: __thiscall exception::exception(char const * const &)" (??0exception@@QAE@ABQBD@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgheap.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgheap.obj)
LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/finaliTest.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
我是这个visual C++ 的新手。我应该如何处理?
-
DllMain的代码:#include "stdafx.h" #include "IDT_DUKPT.h" unsigned char stringKSN[10]; unsigned char m_nderivation_key[16]; unsigned char m_ninitial_key[16]; BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } void OnDecryption(){ GetKey(stringKSN, m_nderivation_key, m_ninitial_key); // Initialization of the method are written in `.lib` file. }
IDT_DUKPT.H 在哪里:
//IDT_DUKPT.h
#define _IDT_DUKPT_H_
// TDES Encryption
void TDES_Encryption(BYTE *Data, BYTE *Key, BYTE *InitalVector, int Length);
// TDES Decryption
void TDES(BYTE *Data, BYTE *Key, BYTE *InitalVector, int Length);
// Get the Initial Key
void GetKey(BYTE *KSN, BYTE *BDK, BYTE *InitialKey);
我还将IDT_DUKPT.lib 放在我的项目文件夹中,并将.lib 链接添加到项目设置中。
我的主要目标是创建一个dll,这样我就可以使用JNA 中的java 代码中的方法。
`
【问题讨论】:
标签: c++ visual-c++ dll msvcr90.dll .lib