Problème d'export/import de DLL
Bonjour,
Je solicite votre aide car j'ai un problème de compilation lors de l'utilisation d'une DLL que j'ai créée.
Je suis sous windows et j'utilise MinGW.
Voici un code minimal reproduisant l'erreur.
Dans un projet Base se trouve le code de ma DLL.
base.hpp
Code:
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
|
#ifndef BASE_HPP_
#define BASE_HPP_
#ifdef BUILDING_DLL
#ifdef __GNUC__
#define DLL_PUBLIC __attribute__((dllexport))
#else
#define DLL_PUBLIC __declspec(dllexport)
#endif
#else
#ifdef __GNUC__
#define DLL_PUBLIC __attribute__((dllimport))
#else
#define DLL_PUBLIC __declspec(dllimport)
#endif
#endif
template <int N>
class DLL_PUBLIC Base
{
public:
virtual void toto ()
{
}
};
#endif /* BASE_HPP_ */ |
base.cpp
Le programme utilisant la DLL est seulement composé d'un main.cpp
main.cpp
Code:
1 2 3 4 5 6 7 8 9 10
|
#include <base.hpp>
int main ()
{
Base<0> t;
t.toto();
return 0;
} |
La compilation de la DLL
g++ -DBUILDING_DLL -O0 -g3 -Wall -c -fmessage-length=0 -obase.o ..\base.cpp
g++ -shared -olibbase.dll base.o
Build complete for project base
La compilation du programme main
g++ -IC:\Users\Loyann\Documents\eclipse_workspaces\dll\base -O0 -g3 -Wall -c -fmessage-length=0 -omain.o ..\main.cpp
g++ -LC:\Users\Loyann\Documents\eclipse_workspaces\dll\main -omain.exe main.o -lbase
main.o: dans la fonction « Base »:
C:/Users/Loyann/Documents/eclipse_workspaces/dll/base/base.hpp:20: référence indéfinie vers « _imp___ZTV4BaseILi0EE »
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Peut-être un oubli de option de g++ dans la compilation de l'un des deux projets.
Merci d'avance pour votre aide. ;)