Bonjour a tous !

Voilà, je cherche à générer une DLL, en temps normal j'y arrive sauf que cette fois ma DLL doit permettre dexporter une classe c++.

Méthode utilisée :

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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
// Fichier.h
#ifndef __MAIN_H__
#define __MAIN_H__
 
 
 
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sstream>
 
 
class __declspec( dllimport )Fichier
{
    public:
        Fichier();
        Fichier(std::string i__filePathInput, std::string i__filePathOutput, int codeConversion);
        std::string getFilePathInput();
        std::string getFilePathOutput();
        int getCodeConversion();
        void setFilePathInput(std::string i__filePathInput);
        void setFilePathOutput(std::string i__filePathOutput);
        void setCodeConversion(int codeConversion);
        int openFile(std::string i__filePath, rt_buffer* o__buffer);
        void readImage();
        void writeImage();
    private:
        std::string m__filePathInput;
        std::string m__filePathOutput;
        int m__codeConversion;
};
 
#endif // __MAIN_H__
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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
 
#include "Fichier.h"
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sstream>
 
using namespace std;
 
 
__declspec( dllexport )Fichier::Fichier()
{
}
__declspec( dllexport )Fichier::Fichier(string i__filePathInput, string i__filePathOutput, int i__codeConversion) : m__filePathInput(i__filePathInput), m__filePathOutput(i__filePathOutput), m__codeConversion(i__codeConversion)
{
}
 
__declspec( dllexport )string Fichier::getFilePathInput()
{
}
__declspec( dllexport )string Fichier::getFilePathOutput()
{
}
__declspec( dllexport )int Fichier::getCodeConversion()
{
}
 
__declspec( dllexport )void Fichier::setFilePathInput(string i__filePathInput)
{
}
__declspec( dllexport )void Fichier::setFilePathOutput(string i__filePathOutput)
{
}
__declspec( dllexport )void Fichier::setCodeConversion(int i__codeConversion)
{
}
 
__declspec( dllexport )int Fichier::openFile(string i__filePath, rt_buffer* o__buffer)
{
}
 
__declspec( dllexport )void Fichier::readImage()
{
}
__declspec( dllexport )void Fichier::writeImage()
{
}
je précise que je link également vers une lib statique que j'utilise pour générer cette DLL


Ensuite lorsque je veux utiliser cette DLL, je créer un projet console et je link le .lib de ma dll.

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
16
17
18
19
 
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sstream>
#include "Fichier.h"
 
using namespace std;
 
int main()
{
    cout << "Hello world!" << endl;
    Fichier l__file1("C:\\image.jpg", "C:\\image2", 3);
 
 
 
    l__file1.convert();
}
Et bien je me retrouve face à cette erreure de compilation :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Fichier::~Fichier(void)" (__imp_??1Fichier@@QAE@XZ) referenced in function _main
bin\Release\useDLL.exe : fatal error LNK1120: 1 unresolved externals
Merci d'avance a ceux qui pourront bien m'aider