Faire une DLL pour Free Pascal avec MinGW
Bonjour !
Je voudrais faire une DLL avec MinGW, qui soit utilisable dans un programme Free Pascal. Voici le modèle actuel de ma DLL, avec un programme de test (en C) et un script pour compiler le tout :
Code:
1 2 3 4 5 6 7 8
| /* mydll.c */
#include <string.h>
__declspec(dllexport) int __cdecl MaFonction(char ch[])
{
return strlen(ch);
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| /* usemydll.c */
#include <stdlib.h>
#include <stdio.h>
__declspec(dllimport) int __cdecl MaFonction(char ch[]);
int main(int argc, char** argv)
{
char c[] = "";
printf("%d\n", MaFonction(c));
return EXIT_SUCCESS;
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| @echo off
rem build-all.cmd
for %%f in (*.dll *.exe *.o) do del %%f
set path=c:\mingw\bin
set dll=mydll
set exe=usemydll
rem http://www.transmissionzero.co.uk/computing/building-dlls-with-mingw/
gcc.exe -c -o %dll%.o %dll%.c
gcc.exe -o %dll%.dll -s -shared %dll%.o -Wl,--subsystem,windows
gcc.exe -c -o %exe%.o %exe%.c
gcc.exe -o %exe%.exe -s %exe%.o -L. -l%dll%
call %exe%
pause |
A votre avis, cette DLL est-elle utilisable avec Free Pascal ? Avec quel code ?