[DEVC++] Problème de linkage??

Problème de linkage?? [DEVC++] - C++ - Programmation

Marsh Posté le 06-08-2004 à 10:50:57    

Voilà mon problème :  
 
J'essaye d'attaquer une DLL dont je n'ai pas le source.
 
Avec les outil PEXPORT et DLLTOOL j'ai crée un fichier .def qui contient les noms des fonctions et créer une library objet
libskunkcmp.a
 
voici le contenu (une partie) du fichier .def  

LIBRARY SkunkCmp.dll
EXPORTS
??0CCat@@QAE@XZ
??0CChunkFile@@QAE@XZ
??1CCat@@QAE@XZ
??1CChunkFile@@QAE@XZ
??4CCat@@QAEAAV0@ABV0@@Z
??4CChunkFile@@QAEAAV0@ABV0@@Z
?AddChunk@CChunkFile@@QAEHKKPAXKH@Z
?CheckChunkFileSize@CChunkFile@@IAEHK@Z
?Close@CCat@@QAEXXZ
?Close@CChunkFile@@QAEXXZ
?ExpandFile@CCat@@SAHPAD0@Z
?ExtendFileSize@CChunkFile@@IAEHK@Z
?FindChunk@CChunkFile@@IAEPAUCHUNKREC@@KK@Z
?FreeAll@CCat@@QAEXXZ
?FreeFile@CCat@@IAEHPAUFILEHDR@@@Z
?FreeFile@CCat@@QAEHH@Z
?FreeFile@CCat@@QAEHPAD@Z
?GetCurrentFileSize@CChunkFile@@IAEKXZ
?GetFileCount@CCat@@QAEHXZ
?GetFileHdr@CCat@@IAEPAUFILEHDR@@H@Z
?Open@CCat@@QAEHPAD@Z
?Open@CChunkFile@@QAEHPADHK@Z

 
le code de mon main.cpp
 

Code :
  1. #include "skunkcmp.h"
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <windows.h>
  5. #include <string.h>
  6. using namespace std;
  7. char *c1="C:\\FA-18\\Wrapper\\Brief.cmp";
  8. int main(int argc, char *argv[])
  9. {
  10. CCat *myCCat = new CCat() ;
  11. myCCat->Open(c1) ;
  12. system("pause" ) ;
  13. return 0;
  14. }


 
le code du fichier .h associé

Code :
  1. // skunkcmp.h
  2. // my attempt at the class spec for:
  3. //   CCat
  4. #ifndef _DLL_H_
  5. #define _DLL_H_
  6. #if BUILDING_DLL
  7. # define DLLIMPORT __declspec (dllexport)
  8. #else /* Not BUILDING_DLL */
  9. # define DLLIMPORT __declspec (dllimport)
  10. #endif /* Not BUILDING_DLL */
  11. //------------------------------------------------------------------
  12. //   CLASS CCat
  13. //   Supports read/write of a file type called a catalog.
  14. //   A catalog contains one or more compressed data files.
  15. //   The first 32bit word in the file is the number of data files.
  16. //   4 more unknown words follow.  The file record table then follows.
  17. //   It is a table consisting of one entry for each file.  Each entry
  18. //   is of the type FILEHDR (see below).
  19. //------------------------------------------------------------------
  20. typedef struct
  21. {   // 92 bytes for each file in a catalog
  22. //   this table starts at byte 0x14 in the catalog file
  23. //   there is one entry for each file in the catalog
  24. char         filename[64];  // original name of expanded file
  25. int          sizeex;        // original size of expanded_file;
  26. int          sizecmp;       // original size of compressed_file;
  27. char*        offset;        // distance from top of file to the compressed data;
  28. int          unk1;
  29. int          unk2;
  30. char*        filelocation;  // location of expanded and loaded file in memory
  31. int          unk4;
  32. } FILEHDR;
  33. //__declspec(dllexport) void CCat(void);
  34. class DLLIMPORT CCat {
  35. // data members 288 bytes
  36. private:
  37. char       Unk[260];            // unknown  maybe temp storage for compression routine?
  38. int        FileHandle;          // windows assigned file handle
  39. FILEHDR*   pFileHeader;         // pointer to top of FILEHDR table (probably should be public)
  40. int        FileCount;           // number of files in file
  41. int        Unk1;
  42. int        Unk2;
  43. int        Unk3;
  44. int        Unk4;
  45. public:
  46. //
  47. // GetFileCount
  48. //    returns number of files in current CCat
  49.  int   GetFileCount(void);
  50. //
  51. // Open
  52. //    opens file with name pointed to by c1
  53. //    reads the FILEHDR record table from the file
  54. //    returns 0=failure 1=success
  55. int   Open(char* c1);
  56. //
  57. // LoadFile
  58. //    reads and decompresses file with name pointed to by c1
  59. //      from the currently open CCat
  60. //    stores the location of the decompressed file at a
  61. //      location pointed to by p1
  62. //    stores the length of the files at a location
  63. //      pointed to by u1
  64.  int   LoadFile(char* c1,void** p1,unsigned long * u1);
  65. //
  66. // WriteFileToDisk
  67. //    writes a decompressed copy file with index i1 in the
  68. //      currently open CCat to disk into a file named c1
  69. //    i2==1 force overwrite, i2==0 disallow overwrite
  70.  int   WriteFileToDisk(int i1,char* c1,int i2);
  71. //
  72. // LoadFile
  73. //    reads and decompresses file with index i1 in the currently open CCat
  74. //    stores the location of the decompressed file at a
  75. //      location pointed to by p1
  76. //    stores the length of the files at a location
  77. //      pointed to by u1
  78.  int   LoadFile(int i1,void** p1,unsigned long * u1);
  79. //
  80. // FreeAll
  81. //     release all expanded files that have been loaded into memory
  82.  void  FreeAll(void);
  83. //
  84. // Close
  85. //    closes the currently open CCat
  86.  void  Close(void);
  87. //
  88. // FreeFile
  89. //     release file c1 from memory
  90.  int   FreeFile(char* c1);
  91. //
  92. // FreeFile
  93. //     release file i1 from memory
  94.  int   FreeFile(int i1);
  95. //
  96. // LoadAll
  97. //     load all file in catalog.  return number of successful loads
  98. //     the pointers to each expanded file needs to be obtained from
  99. //     the FILEHDR table separately
  100.  int   LoadAll(void);
  101. //
  102. // CCat assignment operator
  103.  CCat& operator=(const CCat& );
  104. //
  105. // ExpandFile
  106. //   expands a single compressed file c1
  107. //     into a single exploded file c2
  108. //   this function is unrelated to the CCat
  109. //     catalogs, and thus is static
  110.  static int   ExpandFile(char* c1,char* c2);
  111. //
  112. // CompressFile
  113. //   compresses a single file c1
  114. //     into a single compressed file c2
  115. //   this function is unrelated to the CCat
  116. //     catalogs, and thus is static
  117. //   the newly compressed file is not openable via the Open function
  118.  static int   CompressFile(char* c1,char* c2);
  119. //   probably determines if file c1 is compressed using
  120. //   the CompressFile function.  Since this is static, it
  121. //   is unlikely that it is usable on the CCat catalogs
  122. static int   IsCompressed(char* c1);
  123. //
  124. // GetFileName
  125. //    returns a pointer to the filename of file with index i1 in the
  126. //      currently open catalog
  127.   char* GetFileName(int i1);
  128. //
  129.      // Constructor
  130.             CCat();   
  131. //
  132. // Destructor
  133.    ~CCat(void);
  134. protected:
  135. //
  136. //**GetFileHdr
  137. //    returns pointer to the file table entry for
  138. //     file c1 in the currently open CCat
  139.  FILEHDR* GetFileHdr(char* c1);
  140. //
  141. //**GetFileHdr
  142. //    returns pointer to the file table entry for
  143. //     file index i1 in the currently open CCat
  144.  FILEHDR* GetFileHdr(int i1);
  145. //
  146. //**LoadFile
  147. //    called by the other LoadFile functions.
  148. //    This is where the real action is.
  149.  int LoadFile(FILEHDR* p1);
  150. //
  151. //**CacheFile
  152. //     this is called from LoadFile(FILEHDR*)
  153. //     allocates space for the file to be loaded,
  154. //     and then acutually reads and decompresses the file
  155. //     and stores the location of the decompressed file into
  156. //     the filelocation slot of the current FILEHDR
  157.  int CacheFile(FILEHDR* p1);
  158. //
  159. //**FreeFile
  160. //     frees up memory for the file referenced by p1
  161. int FreeFile(FILEHDR* p1);
  162. public:
  163. //
  164. //  CreateCatalog
  165. //    opens a dialog box for selecting files
  166. //    to be added to a new catalog file.
  167.  int CreateCatalog(void);
  168. };
  169. #endif /* _DLL_H_ */


 
Mon rapport de compil

Compilateur: Default compiler
Building Makefile: "D:\++p\TestDll\tools\dev\Makefile.win"
Exécution de  make...
make.exe -f "D:\++p\TestDll\tools\dev\Makefile.win" all
g++.exe main.o  -o "Skunkcmp.exe" -L"H:/DEV-CPP/lib" -L"D:/++p/TestDll/tools/dev" -lskunkcmp  
main.o(.text+0x5a):main.cpp: undefined reference to `CCat::CCat()'
main.o(.text+0x6b):main.cpp: undefined reference to `CCat::Open(char*)'
Exécution terminée

 
Comme vous pouvez voir il ne reconnait pas la classe CCat..
 
j'ai dessassemblé  la DLL qui m'intéressait et j'obtiens cela.
A priori par rapport à mon source cela doit correspondre. classe CCat..

Code :
  1. ??0CCat@@QAE@XZ proc near
  2. jmp    ds:__imp_??0CCat@@QAE@XZ ; __declspec(dllimport) CCat::CCat(void)
  3. ??0CCat@@QAE@XZ endp
  4. public: int __thiscall CCat::Open(char *)
  5. ?Open@CCat@@QAEHPAD@Z proc near
  6. jmp ds:__imp_?Open@CCat@@QAEHPAD@Z ; __declspec(dllimport) CCat::Open(char *)
  7. ?Open@CCat@@QAEHPAD@Z endp
  8. ; public: __thiscall CCat::~CCat(void)
  9. ??1CCat@@QAE@XZ proc near       
  10. jmp   ds:__imp_??1CCat@@QAE@XZ ; __declspec(dllimport) CCat::~CCat(void)
  11. ??1CCat@@QAE@XZ endp


 
je vois cela dans la bibliothèque objet (ascii dump)

_?Open@CCat@@QAEHPAD@Z  
__imp__?Open@CCat@@QAEHPAD@Z
 
etc..

 
Je ne vois pas du tout ce que j'ai fait comme erreur  
si quelqu'un peut m'aider


Message édité par Frenchy62620 le 06-08-2004 à 13:57:13
Reply

Marsh Posté le 06-08-2004 à 10:50:57   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed