dll,lib及引用源码
2013-12-26 16:22
246 查看
Lib库
LibA.h
LibA.cpp
DLL库(静态引用)
dll.h
dllmain.cpp
控制台引用代码
Tmain.cpp
LibA.h
#pragma once class LibA { public: LibA(void); ~LibA(void); void show(); };
LibA.cpp
#include "StdAfx.h" #include "LibA.h" #include <iostream> using namespace std; LibA::LibA(void) { } LibA::~LibA(void) { } void LibA::show() { cout<<"LibA show"<<endl; }
DLL库(静态引用)
dll.h
#ifndef _DLL_H_ #define _DLL_H_ #ifdef BUILDING_DLL # define DLLIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define DLLIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ DLLIMPORT void FuncA(void); class DLLIMPORT DllClass { public: DllClass(); virtual ~DllClass(void); void show(); private: }; #endif /* _DLL_H_ */
dllmain.cpp
# define BUILDING_DLL #include "dll.h" #include <windows.h> #include <iostream> using namespace std; DllClass::DllClass() { } DllClass::~DllClass () { } void DllClass::show() { cout<<" Class DLLClass show"<<endl; } DLLIMPORT void FuncA(void) { cout<<"FuncA show"<<endl; } BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ , LPVOID reserved /* Not used. */ ) { switch (reason) { case DLL_PROCESS_ATTACH: break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } /* Returns TRUE on success, FALSE on failure */ return TRUE; }
控制台引用代码
Tmain.cpp
#include "stdafx.h" #include "LibA.h" #include "dll.h" int _tmain(int argc, _TCHAR* argv[]) { LibA liba; liba.show(); DllClass dll; dll.show(); FuncA(); return 0; }
相关文章推荐
- 小笔记 DLL导出 和 Lib引用
- Unity脚本引用原理,修复Unity脚本引用丢失,源码脚本与dll中的脚本引用互换
- Unity脚本引用原理,修复Unity脚本引用丢失,源码脚本与dll中的脚本引用互换 .
- LIB和DLL的引用
- 利用Opencv 3.0源码 + Visual Studio 2013 在window7环境下编译lib及dll
- vs 下调试 引用的DLL源码
- Cocos2d-x win7 + vs2010 配置(如何创建cocos2d-x工程,解决各种头文件包含错误、lib库引用错误 及dll链接错误)
- 自己把几个网上的源码弄成的dll文件,并在winform中引用可行?
- Swig转c++ lib项目到c#可引用的dll
- VS2008下WinRar源码生成dll和 lib总结
- vs2015 引用lib库和dll
- 移动MAS短信API libmySQL.dll无法添加引用
- Cocos2d-x win7 + vs2010 配置(如何创建cocos2d-x工程,解决各种头文件包含错误、lib库引用错误 及dll链接错误)
- 写个dll,引用了自己的lib,lib引用进去了,还老是报错
- 通过lib对动态链接库DLL进行引用的项目,发布时DLL放置的位置
- 通过lib对动态链接库DLL进行引用的项目,发布时DLL放置的位置
- Swig将C++编译lib项目转换为C#可引用的dll[勘误后]
- 05.php_pdo引用不恰当libmysql.dll导致Apache崩溃
- 【UE4学习】18_引用 lib(静态库) 和 dll(动态库)
- mapgis6.7二次开发之vs2008平台下引用dll和lib