21.2 windows_21_Library_Class_DLL_USE 动态库补充2

windows_21_Library_Class_DLL_USE 动态库补充2

  1. // windows_21_Library_Class_DLL_USE.cpp : 定义控制台应用程序的入口点。
  2. //
  3. #include "stdafx.h"
  4. //导入DLL文件
  5. #pragma comment(lib,"../bin/windows_21_Library_Class_DLL.lib")
  6. //需要声明一个类的定义,还需要导入类__declspec( dllimport )
  7. class __declspec( dllimport )CMath
  8. {
  9. public:
  10. int Add( int nAdd1, int nAdd2 );
  11. int Sub( int nSub1, int nSub2 );
  12. };
  13. int _tmain(int argc, _TCHAR* argv[])
  14. {
  15. //使用类
  16. CMath math;
  17. int nAdd = math.Add( 100, 100 );
  18. int nSub = math.Sub( 100, 100 );
  19. printf( "nAdd:%d\nnSub:%d\n", nAdd, nSub );
  20. return 0;
  21. }

来自为知笔记(Wiz)

时间: 2024-08-06 07:57:42

21.2 windows_21_Library_Class_DLL_USE 动态库补充2的相关文章

21.7 windows_21_Library_Variable_DLL_USE 动态库补充7

21.7 windows_21_Library_Variable_DLL_USE  动态库补充7 // windows_21_Library_Variable_DLL_USE.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" //第三步,导入lib文件 #pragma comment(lib,"../debug/windows_21_Library_Variable_DLL.lib") //__declspec(dllimpor

21.1 windows_21_Library_Class_DLL 动态库补充1

windows_21_Library_Class_DLL 动态库补充1 #include "windows_21_Library_Class_DLL.h" int CMath::Add( int nAdd1, int nAdd2 ) { return nAdd1 + nAdd2; } int CMath::Sub( int nSub1, int nSub2 ) { return nSub1 - nSub2; } 来自为知笔记(Wiz)

21.4 windows_21_Library_use_DLL 动态库补充4

windows_21_Library_use_DLL  动态库补充4 #include <iostream> using namespace std; //第2.1.1步 导入 lib #pragma comment(lib,"../debug/windows_21_Library_DLL_test.lib") //第2.1.2步 定义函数原型 int Dll_Add( int nAdd1, int nAdd2 ); extern "C"/*如果不加这个

21.5 windows_21_Library_use_DLL_Invoke 动态库补充5

// windows_21_Library_use_DLL_Invoke.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <windows.h> //2.2.2 定义函数指针,在开发工程中,一般都是大写 typedef int( *DLL_ADD )( int nAdd1, int nAdd2 ); typedef int( *DLL_SUB )( int nSub1, int nSub2 ); typedef in

21.3 windows_21_Library_DLL_test&&CPP&&DEF 动态库补充3

windows_21_Library_DLL_test&&CPP&&DEF  动态库补充3 //1.1 创建DLL的项目 //1.2 增加动态库函数 __declspec( dllexport ) //C++导出方式 int Dll_Add( int nAdd1, int nAdd2 ) { return nAdd1 + nAdd2; } //导出函数关键字__declspec( dllexport ) extern "C" __declspec( dl

21.6 windows_21_Library_Variable_DLL&&CPP&&DEF 动态库补充6

windows_21_Library_Variable_DLL&&CPP&&DEF  动态库补充6 CPP //第二步,增加导出声明 __declspec( dllexport )/*增加导出声明*/ //第一步,定义全局变量 int g_nValue1 = 100; // global Variable //第一步,定义DEF导出变量 int g_nValue2 = 200; DEF LIBRARY EXPORTS g_nValue2 @1 DATA 来自为知笔记(Wiz

Go中使用动态库C/C++库

转自:http://studygolang.com/articles/1441 最近需要做一些在go中使用动态C++库的工作,经常碰到找不到动态库路径这种情况,所以就花点时间,专门做一下实验来了解Go. 一.示例代码目录结构(假设代码根目录为/home/gdc/cgotest): ----|bin:----|pkg----|src--------|main------------|main.go--------|oidb------------|hello----------------|hel

linux动态库加载的秘密

摘自http://gotowqj.iteye.com/blog/1926734 摘自http://www.360doc.com/content/14/0313/13/12747488_360246417.shtml linux 下有动态库和静态库,动态库以.so为扩展名,静态库以.a为扩展名.二者都使用广泛.本文主要讲动态库方面知识. 基本上每一个linux 程序都至少会有一个动态库,查看某个程序使用了那些动态库,使用ldd命令查看 # ldd /bin/ls linux-vdso.so.1 =

[转]谈谈Linux下动态库查找路径的问题

http://blog.chinaunix.net/uid-23069658-id-4028681.html 学习到了一个阶段之后,就需要不断的总结.沉淀.清零,然后才能继续“上路”.回想起自己当年刚接触Linux时,不管是用源码包编译程序,还是程序运行时出现的和动态库的各种恩恩怨怨,心里那真叫一个难受.那时候脑袋里曾经也犯过嘀咕,为啥Linux不弄成windows那样呢,装个软件那个麻烦不说,连运行软件都这么恼火呢?如果那样的话就不叫Linux了.借用小米公司CEO雷军一句话:小米,为发烧而生