-
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
51a1ba9
commit 3038122
Showing
8 changed files
with
6,149 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,15 @@ | ||
#include<stdio.h> | ||
void print_GB2312() | ||
{ | ||
FILE *outFile; | ||
unsigned char i,j; | ||
outFile=fopen("gb2312-80.txt","wt"); | ||
for(i=161; i<255; i++) | ||
{ | ||
for(j=161; j<255; j++) | ||
{ | ||
fprintf(outFile,"%c%c,%d,%d\n",i,j,i,j); | ||
} | ||
} | ||
fclose(outFile); | ||
} |
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,37 @@ | ||
gcc���뾲̬��Ͷ�̬�� | ||
|
||
����Ҫ�õ���̬��Ͷ�̬�⣬����д�˼�������������һ�»����� | ||
hello1.c ���������������������������������������� | ||
#include <stdio.h> | ||
void print1(int i) { int j; for(j=0;j<i;j++) { printf("%d * %d = %d\n",j,j,j*j); } } | ||
hello2.c _________________________________________________ | ||
#include <stdio.h> | ||
void print2(char *arr) { char c; int i=0; while((c=arr[i++])!='\0') { printf("%d****%c\n",i,c); } } | ||
hello.c ____________________________________________________ | ||
void print1(int); void print2(char *); | ||
int main(int argc,char **argv) { int i=100; char *arr="THIS IS LAYMU'S HOME!"; print1(i); print2(arr); | ||
return 0; } | ||
|
||
���Կ���hello.cҪ�õ�hello1.c�е�print1������hello2.c�е�print2���������Կ����������������Ϊ�⣬�Թ�����ij�����Ϊ��������á� | ||
|
||
����һ����hello1.c��hello2.c����ɾ�̬���ӿ�.a | ||
[root@localhost main5]#gcc -c hello1.c hello2.c | ||
//��hello1.c��hello2.c�ֱ����Ϊhello1.o��hello2.o������-cѡ����Ϊֻ���벻���ӡ� | ||
[root@localhost main5]#ar -r libhello.a hello1.o hello2.o | ||
//��hello1.o��hello2.o���Ϊlibhello.a�����̬���ӿ� | ||
[root@localhost main5]#cp libhello.a /usr/lib | ||
//��libhello.a������/usr/libĿ¼�£���Ϊһ��ϵͳ�����ľ�̬���ӿ� | ||
[root@localhost main5]#gcc -o hello hello.c -lhello | ||
//��hello.c����Ϊ��ִ�г���hello����������õ���-lhelloѡ����ѡ�����gcc��������/usr/libĿ¼��ȥ��libhello.a�ľ�̬���ӿ� | ||
���ϵĹ���������windows�µ�lib��̬���ӿ�ı��뼰���ù��̡� | ||
����������hello1.o��hello2.o��ϳɶ�̬���ӿ�.so | ||
[root@localhost main5]#gcc -c -fpic hello1.c hello2.c | ||
//��hello1.c��hello2.c�����hello1.o��hello2.o��-c��Ϊֻ���벻���ӣ�-fpic��Ϊλ�ö������룬ָʾ����������ɵĴ���Ҫ�ʺϹ���������������Ĵ����ܹ����������ڴ��λ�ü����ڲ���ַ�� | ||
[root@localhost main5]#gcc -shared hello1.o hello2.o -o hello.so | ||
//��hello1.o��hello2.o���Ϊshared object������̬���ӿ� | ||
[root@localhost main5]#cp hello.so /usr/lib | ||
//��hello.so������/usr/libĿ¼�� | ||
[root@localhost main5]#gcc -o hello hello.c hello.so | ||
//��hello.c��������Ϊhello�Ŀ�ִ�г�����������õ��˶�̬���ӿ�hello.so | ||
|
||
������Ҫ�ϻ����䣬��ʵһ�еĶ�������Ϣ�����������Ļ��ƣ�ֻҪŪ��������Ļ��ƣ����ܹ�ʵ��֮�����κδ�ʱ�˿�������֮�¶�����Ϊ��ʵ����Ȼ��������֮��ľ�蹵��Ҫ���������˼��Ͷ����Ĵ�������Խ�� |
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,10 @@ | ||
//void print_GB2312(); | ||
//print_GB2312(); | ||
#include <iostream> | ||
#include <string> | ||
using namespace std; | ||
string getLetter(string strText); | ||
int main(int argc, char* argv[]) | ||
{ | ||
cout << getLetter("ÖлªÈËÃñ¹²ºÍ¹ú") << endl; | ||
} |
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,89 @@ | ||
vc++��.dll��.lib�ļ���������ʹ�õ���� | ||
-------------------------------------------------------------------------------- | ||
���ֿ⣺ | ||
?���������˺������ڵ�DLL�ļ����ļ��к���λ�õ���Ϣ����ڣ�������������ʱ�����ڽ��̿ռ��е�DLL�ṩ����Ϊ��̬���ӿ�dynamic link library�� | ||
?���������������뱾�����ڱ���ʱֱ�ӽ������������У���Ϊ��̬���ӿ�static link library�� | ||
�����������ӷ�ʽ�� | ||
?������̬����ʹ�ö�̬���ӿ⣬������ִ��ģ�飨.dll�ļ���.exe�ļ���������������ʱ��λDLL�����Ŀ�ִ�д����������Ϣ�� | ||
?������̬����ʹ�þ�̬���ӿ⣬�������Ӿ�̬���ӿ�LIB��ȡ���б����ú�����������ͬ����һ��ŵ���ִ���ļ��С� | ||
|
||
-------------------------------------------------------------------------------- | ||
�����ļ������� | ||
-------------------------------------------------------------------------------- | ||
ʹ��lib��ע�������ļ��� | ||
?.hͷ�ļ�������lib��˵�������������ԭ�ͻ����ݽṹ��Ӧ�ó������libʱ����Ҫ�����ļ�������Ӧ�ó����Դ�ļ��С� | ||
?.LIB�ļ��� | ||
ʹ��dll��ע�������ļ��� | ||
?.hͷ�ļ�������dll��˵�������������ԭ�ͻ����ݽṹ��.h�ļ���Ӧ�ó������dllʱ����Ҫ�����ļ�������Ӧ�ó����Դ�ļ��С� | ||
?.LIB�ļ�����dll�ڱ��롢���ӳɹ�֮�����ɵ��ļ��������ǵ�����Ӧ�ó������dllʱ����Ҫ�����ļ�����Ӧ�ó���������������������lib�ļ�����û��lib�ļ���������WIN32 API����LoadLibrary��GetProcAddressװ�أ��� | ||
?dll�ļ��������Ŀ�ִ���ļ��������ɹ����Ӧ�ó����ڷ���ʱ��ֻ��Ҫ��.exe�ļ���.dll�ļ���������Ҫ.lib�ļ���.hͷ�ļ��� | ||
|
||
-------------------------------------------------------------------------------- | ||
���ɺ�ʹ�÷��� | ||
-------------------------------------------------------------------------------- | ||
����ϵͳ��WIN7 | ||
����������VS2010 | ||
-------------------------------------------------------------------------------- | ||
1.����lib�ļ� | ||
�������ȣ������Ƚ���һ������̨����(�½�->����->����̨����)������add.cpp�Լ�add.h�ļ��� | ||
���ƴ��� ��������: | ||
|
||
//sub.h | ||
#ifndef _SUB_H | ||
#define _SUB_H | ||
void sub(int a,int b); | ||
#endif | ||
//sub.cpp | ||
#include "sub.h" | ||
#include <iostream> | ||
void sub(int a,int b) | ||
{ | ||
std::cout<<(a-b)<<std::endl; | ||
} | ||
���������ڹ����У�û��main()����������ֱ�ӱ����������ʱ��Ҫ�Ҽ�������̣���ѡ�����ԣ�������ͼ��ѡ��̬���ӿ⼴�ɡ� | ||
|
||
������ʱ���ٰ�F7��build solution���ɲ���lib�ļ�����Debug��ֻ����.lib�ļ��� | ||
|
||
2.����dll�ļ� | ||
��������dll�ļ��Ĺ���������Ĺ�����һ���ģ�ֻ����ѡ��Dynamic Library(.dll)���ɡ���Debug�л�����һ��.lib��.dll�����ļ��� | ||
-------------------------------------------------------------------------------- | ||
3.�����ļ���ʹ�� | ||
������ʹ��ʱ����̬���ӿ�ֻҪ��.h��.lib�ļ����뵽�����ļ����м��ɡ�����̬���ӿ�Ҫ��.h��.lib��.dll�ļ����뵽�����С� | ||
���ƴ��� ��������: | ||
|
||
#include <iostream> | ||
#include "sub.h" //���ӿ��ͷ�ļ� | ||
using namespaces std; | ||
#pragma comment(lib,"sub.lib") //�������ӿ� | ||
int main() | ||
{ | ||
sub(5,4); | ||
return 0; | ||
} | ||
|
||
4.����.dll�ļ�ʱ���ʹ�÷��� | ||
������û��.h��.lib�ļ�ʱ����Ҫ����ָ���WIN32 API����LoadLibrary��GetProcAddressװ�أ�ֻ��Ҫ.dll�ļ����ɣ���.dll�ļ����빤��Ŀ¼�У��� | ||
���ƴ��� ��������: | ||
|
||
#include <iostream> | ||
#include <windows.h> //ʹ�ú�����ijЩ������� | ||
typedef void (*DLLFunc)(int,int); //ȷ�����ú������β� | ||
int main() | ||
{ | ||
DLLFunc dllFunc; | ||
HINSTANCE hInstLibrary = LoadLibrary("sub.dll");//����.dll | ||
if (hInstLibrary == NULL) | ||
{ | ||
FreeLibrary(hInstLibrary); | ||
} | ||
dllFunc = (DLLFunc)GetProcAddress(hInstLibrary, "sub");//�ڶ�������ΪҪ���õĺ������� | ||
if (dllFunc == NULL) | ||
{ | ||
FreeLibrary(hInstLibrary); | ||
} | ||
dllFunc(5,4); | ||
FreeLibrary(hInstLibrary); | ||
return(1); | ||
} | ||
|
||
�������һֱ�ڸ�API�ⶫ��������curl��tinyxml��jsoncpp���ֿ�Դ�Ŀ⣬��linux��ʹ�õ��Ǻܷ��㣬��windows�»����Լ�����������˵����⣬��������ѧϰ�£�����~~ |
Oops, something went wrong.