-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
434b058
commit 2643ccb
Showing
3 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
Windows��� MD(d)��MT(d)����ѡ������� | ||
��ǩ�� windows��̶��߳�dllgeneration | ||
2012-05-09 16:27 9201���Ķ� ����(0) �ղ� �ٱ� | ||
���ࣺ windows��̣�20�� | ||
Ŀ¼(?)[+] | ||
1������ѡ���λ�� | ||
��VS2005Ϊ���������Ӵ� | ||
|
||
1�� ����Ŀ��Property Pages�Ի��� | ||
|
||
2�� ������C/C++�� | ||
|
||
3�� ���Code Generation�� | ||
|
||
4�� �Ҳ������Runtime Library��Ŀ | ||
|
||
2����������ѡ������ĺ��� | ||
����ѡ�� | ||
|
||
���� | ||
|
||
��̬���ӵ�lib | ||
|
||
˵�� | ||
|
||
/MD | ||
|
||
_MT��_DLL | ||
|
||
MSVCRT.lib | ||
|
||
���̡߳�Release��DLL�汾������ʱ�� ---ֻ������Release�汾 | ||
|
||
/MDd | ||
|
||
_DEBUG��_MT��_DLL | ||
|
||
MSVCRTD.lib | ||
|
||
���̡߳�Debug��DLL�汾������ʱ�� ----ֻ������Debug�汾 | ||
|
||
/MT | ||
|
||
_MT | ||
|
||
LIBCMT.lib | ||
|
||
���̡߳�Release�汾������ʱ�� | ||
|
||
/MTd | ||
|
||
_DEBUG��_MT | ||
|
||
LIBCMTD.lib | ||
|
||
���̡߳�Debug�汾������ʱ�� | ||
|
||
|
||
|
||
��˵�� | ||
|
||
��1��/MD����ʾ����ʱ���ɲ���ϵͳ�ṩһ��DLL�������ﲻ���ɡ� | ||
|
||
��2��/MT����ʾ����ʱ���ɳ���,��������Ҫ����ϵͳ�ṩ����ʱ��DLL�� | ||
|
||
|
||
|
||
/MT��"multithread, static version" ��˼�Ƕ��߳̾�̬�İ汾������������������LIBCMT.lib���õ�OBJ�ļ��У���������ʹ��LIBCMT.lib �����ⲿ���š� | ||
/MD��"multithread- and DLL-specific version"����˼�Ƕ��߳�DLL�汾������������������MSVCRT.lib���õ�OBJ�ļ��У������ӵ�DLL�ķ�ʽ�Ǿ�̬���ӣ�ʵ���Ϲ����Ŀ���MSVCR80.DLL�� | ||
���� | ||
��̬����ʱ�⣺LIBCMT.lib | ||
��̬����ʱ�⣺MSVCRT.lib +MSVCR80.DLL | ||
����/MD��/MT��ѡ�� | ||
1��Ϊʲôѡ��/MD����ѡ/MT�� | ||
��1������Ͳ���Ҫ��̬��������ʱ�⣬���Լ�С�����Ĵ�С�� | ||
|
||
��2�����е�ģ�鶼����/MD��ʹ�õ���ͬһ���ѣ�������A�����룬B���ͷŵ����⡣ | ||
|
||
2��Ϊʲôѡ��/MT����ѡ��/MD�� | ||
��1����Щϵͳ����û�г�������Ҫ�汾������ʱ�⣬������������ʱ�⾲̬�����ϡ� | ||
|
||
3�����ģ�飬����ѡ����ͬ���͵�����ʱ�⣬��Ҫ���ʹ�á� | ||
|
||
|
||
|
||
|
||
����ѡ��/MT��Ҫ����Ķѿռ��ͷ����� | ||
��ͬ��ģ�������һ��C����ʱ����룬����C���п���и��ԵĶѣ������˸���ģ����и��ԵĶѡ������A��������ռ䣬��B�����ͷžͻ��б�������ģ��A����Ŀռ䣬������ģ��A���ͷš� | ||
|
||
���������ص�ַ��http://files.cnblogs.com/cswuyg/Test_MD_and_MT.rar����DLL�Լ�DLLUser���룬��STL��stringΪ����ͨ���ı���ѡ����֤��������⡣(string�ڸ�ֵ��ʱ����Ҫ�ͷŵ�ԭ���Ŀռ䣬Ȼ���������µĿռ�洢�µ����ݡ�) | ||
|
||
|
||
|
||
�ġ��ο����� | ||
1��������MT��MD�ȵ���ϸ���� | ||
|
||
http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=VS.71).aspx | ||
|
||
2����Ҫ����Aģ�����룬Bģ���ͷŵ���� | ||
|
||
http://www.cnblogs.com/minggoddess/archive/2010/12/15/1907179.html | ||
|
||
3������ʱ������Щ�汾 | ||
|
||
http://www.cppblog.com/MichaelLiu/articles/10607.html | ||
|
||
4��CSDN�Ϲ��ڶѿռ��ͷŵ����� | ||
|
||
http://topic.csdn.net/t/20010112/09/57983.html | ||
|
||
http://topic.csdn.net/t/20031009/17/2338051.html | ||
|
||
http://topic.csdn.net/u/20090502/00/bf1602e3-ddf5-49b0-af81-8a23383f9ddc.html | ||
|
||
http://blog.csdn.net/blz_wowar/article/details/2176536 | ||
|
||
5����ͬģ�鲻ͬ�Ķ� | ||
|
||
http://www.cnblogs.com/WengYB/archive/2011/08/18/2144727.htm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
void hzInFile (CString FileName) | ||
{ | ||
FILE *in; | ||
unsigned char c1, c2; | ||
int id; | ||
in=fopen((const char *)FileName, "rb"); | ||
if(in==NULL) | ||
{ | ||
AfxMessageBox("无法打开输入文件!"); | ||
return; | ||
} | ||
while (!feof (in)) | ||
{ | ||
c1=(unsigned char ) fgetc(in); // 转换为无符号字符 | ||
if(c1<128) | ||
continue; // 不处理单字节西文字符 | ||
if(c1<176) | ||
{ | ||
c2=fgetc(in); | ||
continue; | ||
} // 也不处理非汉字字符,但要多读一个字节 | ||
c2=(unsigned char ) fgetc(in); // 读入汉字的第二个字节 | ||
id=HZ_ID(c1,c2); // 计算该汉字的下标 | ||
HZFreq[id]++; // 给该汉字的频度加1 | ||
} | ||
fclose(in); | ||
return; | ||
} | ||
void OnSingleHz() | ||
{ | ||
// 单字字频统计 | ||
for(int i=0; i<HZ_NUM; i++) HZFreq[i]=0; | ||
ProcessFiles(hzInFile); | ||
FILE *outFile; | ||
outFile=fopen("hzfreq.txt", "wt"); | ||
for(int id=0; id<HZ_NUM; id++) | ||
if(HZFreq[id]>0) | ||
fprintf(outFile, "%c%c\t%d\n", id/94+176, id%94+161, HZFreq[id]); | ||
fclose(outFile); | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
��VS�д�����ʹ��DLL��̬���ӿ� | ||
|
||
VS��ʹ�ö�̬���ӿ��GCC������ | ||
|
||
��VS���½�����ʱ����dll���� | ||
��dll���̵�ͷ�ļ��м������º� | ||
|
||
#ifdef DLL_IMPLEMENT_ | ||
#define DLL_APL __declspec(dllexport) | ||
#else | ||
#define DLL_API __declspec(dllimport) | ||
#endif | ||
__declspec(dllimport)��__declspec(dllexport)������ijһ����ĵ���/�������� | ||
|
||
��dll��ʵ���ļ�ͷ��ʹ�ú꽫������Ϊdll�ڲ���ʵ�� | ||
|
||
#define DLL_IMPLEMENT_ | ||
��ʹ��dll�Ĺ��̺�dll����ͬ��һ������������ڽ�����������������úù��̵�������ϵ����ʹ��dll�Ĺ��̵����������ú�ͷ�ļ��Ϳ��ļ���·��������ֱ�ӱ������У���Ҫע����ǣ�VS����ʹ��dll�ij���ʱ����Ȼ��Ҫ��dll��Ӧ��lib�ļ�����gccֱ�ӿ������Ӷ�̬��������ͬ | ||
���Խ�һ��dll��������ݰ�����һ�������ռ�����������ռ�Ķ�����Բ�����������Ҳ�����ʵ�ֺͽӿڵķ������ʲô�鷳 | ||
|
||
�������� | ||
|
||
DLLͷ�ļ��� DLLtest.h | ||
|
||
#ifndef _TEST_H_ | ||
#define _TEST_H_ | ||
|
||
#ifdef DLL_IMPLEMENT_ | ||
#define DLL_API __declspec(dllexport) | ||
#else | ||
#define DLL_API __declspec(dllimport) | ||
#endif | ||
|
||
namespace dll | ||
{ | ||
int DLL_API add(const int &a, const int &b); | ||
int DLL_API sub(const int &a, const int &b); | ||
int DLL_API mul(const int &a, const int &b); | ||
int DLL_API div(const int &a, const int &b); | ||
} | ||
|
||
#endif | ||
DLLʵ���ļ���DLLtest.cpp | ||
|
||
#define DLL_IMPLEMENT_ | ||
#include "test.h" | ||
|
||
namespace dll | ||
{ | ||
int add(const int &a, const int &b) | ||
{ | ||
return a + b; | ||
} | ||
|
||
int sub(const int &a, const int &b) | ||
{ | ||
return a - b; | ||
} | ||
|
||
int mul(const int &a, const int &b) | ||
{ | ||
return a * b; | ||
} | ||
|
||
int div(const int &a, const int &b) | ||
{ | ||
return a / b; | ||
} | ||
} | ||
Ӧ�ó���:entry.cpp | ||
|
||
#include "test.h" | ||
#include <iostream> | ||
|
||
#pragma comment(lib, "DLLtest.lib") | ||
|
||
using namespace std; | ||
using namespace dll; | ||
|
||
int main() | ||
{ | ||
int a, b; | ||
char c; | ||
while( cin >> a >> c >> b ) | ||
{ | ||
switch( c ) | ||
{ | ||
case '+': | ||
cout << add(a, b) << endl; | ||
break; | ||
case '-': | ||
cout << sub(a, b) << endl; | ||
break; | ||
case '*': | ||
cout << mul(a, b) << endl; | ||
break; | ||
case '/': | ||
cout << dll:: div(a, b) << endl; | ||
break; | ||
default: | ||
cout << '\"' << a << c << b << '\"' << "isn't a valid expression." << endl; | ||
} | ||
} | ||
} | ||
Written with StackEdit. |