Bonjour,
Je souhaite utiliser "readpst" dans mon programme. Pour cela j'essaie de compiler une dll en modifiant légèrement ses sources.

Je suis sous Windows 7 64 et j'utilise mingw pour compiler.

Readpst utilise deux DLL (GNU Regex for Win32 et GNU ICONV for Win32) et je peux créer l’exécutable avec cette ligne de commande (que j'ai trouvé ici):

"c:\MinGW\bin\mingw32-gcc.exe" -DHAVE_REGEX_H -I"c:\Program Files (x86)\GnuWin32\include" -include "C:\MinGW\include\inttypes.h" -DVERSION=\"0.6.45\" -include "C:\MinGW\include\errno.h" -include "C:\MinGW\include\sys\stat.h" -include "C:\MinGW\include\limits.h" -DHAVE_ICONV -DICONV_CONST=const -L"c:\Program Files (x86)\GnuWin32\lib" debug.c libpst.c vbuf.c -liconv libstrfunc.c timeconv.c lzfu.c readpst.c -lregex -o readpst.exe
Cette ligne de commande fonctionne chez moi et me génère donc readpst.exe.

Maintenant je veux créer une DLL avec pour seul et unique fonction la fonction main() que je renomme au passage en readpst_main().

Pour ca, je creer un nouveau fichier readpst.h:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
#ifndef READPST_H
#define READPST_H
 
__declspec(dllimport) int readpst_main(int argc, char* const* argv);
 
//READPST_H
#endif
et je rajoute au readpst.c existant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
__declspec(dllexport) int readpst_main(int argc, char* const* argv) *
{
...
}
J'ai l'impression que la syntaxe est bonne jusqu'ici, mon problème viens de la ligne de commande pour compiler la DLL.

En effet je tente ceci pour compiler ma DLL:
mingw32-gcc.exe -c -DHAVE_REGEX_H -DHAVE_ICONV -DICONV_CONST=const -DVERSION=\"0.6.45\" -I"GnuWin32\include" -include "MinGW\include\errno.h" -include "MinGW\include\sys\stat.h" -include "MinGW\include\limits.h" -include "MinGW\include\inttypes.h" -L"GnuWin32\lib" -liconv -lregex debug.c libpst.c vbuf.c libstrfunc.c timeconv.c lzfu.c readpst.c

mingw32-gcc.exe -shared -include "MinGW\include\errno.h" -include "MinGW\include\sys\stat.h" -include "MinGW\include\limits.h" -include "MinGW\include\inttypes.h" -L"GnuWin32\lib" -liconv -lregex -o readpst.dll debug.o libpst.o libstrfunc.o lzfu.o readpst.o timeconv.o vbuf.o -Wl,--out-implib,readpst.a
et la j'ai les erreurs suivantes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Creating library file: readpst.a
readpst.o:readpst.c:(.text+0xa1c): undefined reference to `_imp__regcomp'
readpst.o:readpst.c:(.text+0x1210): undefined reference to `_imp__regfree'
readpst.o:readpst.c:(.text+0x3253): undefined reference to `_imp__regexec'
vbuf.o:vbuf.c:(.text+0xc3): undefined reference to `_imp__libiconv_close'
vbuf.o:vbuf.c:(.text+0xdb): undefined reference to `_imp__libiconv_close'
vbuf.o:vbuf.c:(.text+0x12c): undefined reference to `_imp__libiconv_open'
vbuf.o:vbuf.c:(.text+0x181): undefined reference to `_imp__libiconv_open'
vbuf.o:vbuf.c:(.text+0x243): undefined reference to `_imp__libiconv'
vbuf.o:vbuf.c:(.text+0x2f9): undefined reference to `_imp__libiconv_close'
vbuf.o:vbuf.c:(.text+0x311): undefined reference to `_imp__libiconv_close'
vbuf.o:vbuf.c:(.text+0x329): undefined reference to `_imp__libiconv_close'
vbuf.o:vbuf.c:(.text+0x772): undefined reference to `_imp__libiconv_open'
vbuf.o:vbuf.c:(.text+0x85e): undefined reference to `_imp__libiconv'
collect2: ld a retourné 1 code d'état d'exécution
Je n'arrive pas à linker avec gnu ioconv et gnu regex. C'est surement un problème de syntaxe mais je n'arrive pas à trouver quoi.

Avez vous une idée?

ps : j'ai simplifié les chemins pour la ligne de commande mais j'utilise les même que ceux de la compilation d'exe qui fonctionne, j'en déduis donc qu'ils sont bon.