0
我有4個文件:創建.dll文件
mySender.h mySender.cpp myReceiver.h myReceiver.cpp
我想要導入這些4文件的一個.dll項目「 MyIfa「在VisualStudio 2012中。 我創建了一個新項目---> win32 --->我在嚮導中選擇了導出外部符號---->至少創建了項目(新文件夾是用所有組件創建的)。
現在我需要做什麼?
- 添加四個文件(添加現有的項目)在我的項目和建設?
- 在我的項目中添加四個文件(添加現有項目),包括.h 文件(mySender.h,myReceiver.h)和building?
- 添加四個文件(添加現有項)在我的項目,包括.H 文件(mySender.h,myReceiver.h),增加額外的目錄和 庫(我使用mySender.h,myReceiver.h ,mySender.cpp, myReceiver.cpp)在項目屬性和建築?
這是產生新的代碼: IfacomAmqDll.h
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the IFACOMAMQDLL_EXPORTS
// symbol defined on the command line. This symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// IFACOMAMQDLL_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef IFACOMAMQDLL_EXPORTS
#define IFACOMAMQDLL_API __declspec(dllexport)
#else
#define IFACOMAMQDLL_API __declspec(dllimport)
#endif
// This class is exported from the IfacomAmqDll.dll
class IFACOMAMQDLL_API CIfacomAmqDll {
public:
CIfacomAmqDll(void);
// TODO: add your methods here.
};
extern IFACOMAMQDLL_API int nIfacomAmqDll;
IFACOMAMQDLL_API int fnIfacomAmqDll(void);
這IfacomAmqDll.cpp:
// IfacomAmqDll.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "IfacomAmqDll.h"
// This is an example of an exported variable
IFACOMAMQDLL_API int nIfacomAmqDll=0;
// This is an example of an exported function.
IFACOMAMQDLL_API int fnIfacomAmqDll(void)
{
return 42;
}
// This is the constructor of a class that has been exported.
// see IfacomAmqDll.h for the class definition
CIfacomAmqDll::CIfacomAmqDll()
{
return;
}
所以我需要用我現有的.h和做。 cpp文件能夠導出所有在裏面定義的類?
對於我在源代碼中使用的lybraries,您認爲這樣可以嗎?我的意思是... .dll知道如何鏈接所有? – CecchinoSMI
@CecchinoSMI如果您現有的代碼對第三方庫具有任何依賴性,那麼您將不得不將它們添加到項目屬性中,或者(更好地)在源代碼中通過#pragma註釋(lib,「somelib.lib」)來執行它etc. –
我很習慣操縱項目屬性中的所有依賴......所以我認爲我以這種方式進行...... – CecchinoSMI