C:\_32\c>type double.h
double __declspec(dllexport) my_double(int);
C:\_32\c>
####
C:\_32\c>type double.c
#include "double.h"
double __declspec(dllexport) my_double(int num) {
return (double) num;
}
C:\_32\c>
####
C:\_32\c>cl /Gz /LD double.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.
double.c
Microsoft (R) Incremental Linker Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.
/out:double.dll
/dll
/implib:double.lib
double.obj
Creating library double.lib and object double.exp
C:\_32\c>
####
C:\_32\c>dumpbin /exports double.dll
Microsoft (R) COFF/PE Dumper Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file double.dll
File Type: DLL
Section contains the following exports for double.dll
00000000 characteristics
4837FFED time date stamp Sat May 24 19:45:49 2008
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
1 0 00001000 _my_double@4
Summary
2000 .data
2000 .rdata
1000 .reloc
7000 .text
C:\_32\c>
####
C:\_32\c>type double.pl
use Win32::API;
use warnings;
$function = Win32::API->new('double', 'my_double', 'N', 'D');
$ret = $function->Call(123);
print $ret, "\n";
C:\_32\c>
####
C:\_32\c>perl double.pl
Can't call method "Call" on an undefined value at double.pl line 5.
C:\_32\c>
####
C:\_32\c>type double_test.c
#include
#include "double.h"
int main(void) {
double d = my_double(123);
printf("%f\n", d);
return 0;
}
C:\_32\c>
####
C:\_32\c>cl double_test.c double.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.
double_test.c
Microsoft (R) Incremental Linker Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.
/out:double_test.exe
double_test.obj
double.lib
double_test.obj : error LNK2019: unresolved external symbol _my_double reference
d in function _main
double_test.exe : fatal error LNK1120: 1 unresolved externals
C:\_32\c>
####
C:\_32\c>cl -c double.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.
double.c
C:\_32\c>
####
C:\_32\c>cl double_test.c double.obj
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.
double_test.c
Microsoft (R) Incremental Linker Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.
/out:double_test.exe
double_test.obj
double.obj
Creating library double_test.lib and object double_test.exp
C:\_32\c>
####
C:\_32\c>double_test.exe
123.000000
C:\_32\c>