24,854
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
extern "C" {
__declspec(dllexport) void hello(char *msg);
}
void hello(char *msg){
printf("Hello %s\n",msg);
}
g++ -shared -Wl,--kill-at,--output-def,dll.def -o dll.dll dll.cpp
#include <stdio.h>
extern "C" {
__declspec(dllimport) void hello(char *msg);
}
int main(int argc, char *argv[])
{
hello("Fucking!");
return 0;
}
g++ -L. -ldll -o test.exe test.cpp
Hello Fucking!
>dumpbin /exports dll.dll
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file dll.dll
File Type: DLL
Section contains the following exports for dll.dll
00000000 characteristics
50006CA6 time date stamp Sat Jul 14 02:44:54 2012
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
1 0 00001194 hello
Summary
1000 .CRT
1000 .bss
1000 .data
1000 .debug_abbrev
1000 .debug_aranges
1000 .debug_frame
3000 .debug_info
1000 .debug_line
1000 .debug_loc
1000 .debug_pubnames
1000 .debug_pubtypes
1000 .debug_ranges
1000 .debug_str
1000 .edata
1000 .idata
1000 .rdata
1000 .reloc
1000 .text
1000 .tls