Error LNK2019: unresolved external symbol

Résolu
chalmia2s Messages postés 31 Date d'inscription mercredi 18 février 2009 Statut Membre Dernière intervention 15 octobre 2009 - 11 mai 2009 à 11:10
chalmia2s Messages postés 31 Date d'inscription mercredi 18 février 2009 Statut Membre Dernière intervention 15 octobre 2009 - 11 mai 2009 à 13:11
Bonjour,

il y avait une Librairie écrite en C++, avec 3 projets: deux application console et une dll, je voulais modifier le continue d'un des projets (qui etait une application console) et la changer en dll .

J'ai changé les propriétes des deux application consoles ainsi:
- Configuration properties/ C/C++/ Code Generation/ Runtime library: 
         en: Mult-threaded Debug DLL(/MDd)
- Configuration properties/ Linker/ General/ Output File: 
         en: $(OutDir)\$(ProjectName).dll
- Configuration properties/ Linker/ System/ SubSystem: 
         en: Windows (/SUBSYSTEM:WINDOWS)  

Mais j'obtiens les erreurs suivantes: 

Linking...

1> Creating library .\Debug\sample.lib and object .\Debug\sample.exp
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>.\Debug\sample.dll : fatal error LNK1120: 1 unresolved externals


Quelqu'un aurait une idee de comment pouvoir resoubre ce probleme?

Merci
   
A voir également:

4 réponses

fregolo52 Messages postés 1114 Date d'inscription mercredi 15 juin 2011 Statut Membre Dernière intervention 6 mai 2021 4
11 mai 2009 à 12:07
les fonctions annClose & Co doivent etre dans une dll.

Regarde dans Configuration properties/Linker /input /Add dependencies de ton ancien exe console, il doit y avoir un ou plusieur fichier .lib de dépendance.
3
fregolo52 Messages postés 1114 Date d'inscription mercredi 15 juin 2011 Statut Membre Dernière intervention 6 mai 2021 4
11 mai 2009 à 11:27
le mieux est de créer une DLL avec le wizard de Visual et d'intégrer les fichiers cpp au projet.

Configuration properties/ General / Configuration Type : as-tu DLL ?

Une appli console n'est pas une DLL, tu auras d'autres soucis.
0
chalmia2s Messages postés 31 Date d'inscription mercredi 18 février 2009 Statut Membre Dernière intervention 15 octobre 2009
11 mai 2009 à 11:50
oui j'avais commencer a faire comme ça, creer un nouveau projet  dll et copier les fichier dedans , mais j'avais plusieurs erreur, comme par exemple:
1>Édition des liens en cours...
1> Création de la bibliothèque
C:\...\dllkey\Debug\anntest.lib et de l'objet
C:\...\dllkey\Debug\anntest.exp
1>ann.obj : error LNK2019: symbole externe non résolu "__declspec(dllimport) void __cdecl annClose(void)" (__imp_?annClose@@YAXXZ) référencé dans la fonction "long __cdecl ann(struct lme_ref_struct *,long,long)" (?ann@@YAJPAUlme_ref_struct@@JJ@Z)

1>ann.obj : error LNK2019: symbole externe non résolu "__declspec(dllimport) public: __thiscall ANNkd_tree::ANNkd_tree(double * *,int,int,int,enum ANNsplitRule)" (__imp_??0ANNkd_tree@@QAE@PAPANHHHW4ANNsplitRule@@@Z) référencé dans la fonction "long __cdecl ann(struct lme_ref_struct *,long,long)" (?ann@@YAJPAUlme_ref_struct@@JJ@Z)

1>ann.obj : error LNK2019: symbole externe non résolu "__declspec(dllimport) double * * __cdecl annAllocPts(int,int)" (__imp_?annAllocPts@@YAPAPANHH@Z) référencé dans la fonction "long __cdecl ann(struct lme_ref_struct *,long,long)" (?ann@@YAJPAUlme_ref_struct@@JJ@Z)

1>ann.obj : error LNK2019: symbole externe non résolu "__declspec(dllimport) double * __cdecl annAllocPt(int,double)" (__imp_?annAllocPt@@YAPANHN@Z) référencé dans la fonction "long __cdecl ann(struct lme_ref_struct *,long,long)" (?ann@@YAJPAUlme_ref_struct@@JJ@Z)

1>ann.obj : error LNK2001: symbole externe non résolu "public: virtual void __thiscall ANNkd_tree::annkSearch(double *,int,int *,double *,double)" (?annkSearch@ANNkd_tree@@UAEXPANHPAH0N@Z)

1>ann.obj : error LNK2001: symbole externe non résolu "public: virtual int __thiscall ANNkd_tree::annkFRSearch(double *,double,int,int *,double *,double)" (?annkFRSearch@ANNkd_tree@@UAEHPANNHPAH0N@Z)

1>ann.obj : error LNK2001: symbole externe non résolu "public: virtual int __thiscall ANNkd_tree::theDim(void)" (?theDim@ANNkd_tree@@UAEHXZ)

1>ann.obj : error LNK2001: symbole externe non résolu "public: virtual int __thiscall ANNkd_tree::nPoints(void)" (?nPoints@ANNkd_tree@@UAEHXZ)

1>ann.obj : error LNK2001: symbole externe non résolu "public: virtual double * * __thiscall ANNkd_tree::thePoints(void)" (?thePoints@ANNkd_tree@@UAEPAPANXZ)

1>ann.obj : error LNK2001: symbole externe non résolu "public: virtual void __thiscall ANNkd_tree::Print(enum ANNbool,class std::basic_ostream<char,struct std::char_traits<char> > &)" (?Print@ANNkd_tree@@UAEXW4ANNbool@@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)

1>ann.obj : error LNK2001: symbole externe non résolu "public: virtual void __thiscall ANNkd_tree::Dump(enum ANNbool,class std::basic_ostream<char,struct std::char_traits<char> > &)" (?Dump@ANNkd_tree@@UAEXW4ANNbool@@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)

1>ann.obj : error LNK2001: symbole externe non résolu "public: virtual void __thiscall ANNkd_tree::getStats(class ANNkdStats &)" (?getStats@ANNkd_tree@@UAEXAAVANNkdStats@@@Z)

1>ann.obj : error LNK2019: symbole externe non résolu "__declspec(dllimport) public: virtual __thiscall ANNkd_tree::~ANNkd_tree(void)" (__imp_??1ANNkd_tree@@UAE@XZ) référencé dans la fonction "public: virtual void * __thiscall ANNkd_tree::`scalar deleting destructor'(unsigned int)" (??_GANNkd_tree@@UAEPAXI@Z)

1>C:\...\dllkey\Debug\anntest.dll : fatal error LNK1120: 13 externes non résolus

je ne sais pas ce qui ne va pas vraiment...
0
chalmia2s Messages postés 31 Date d'inscription mercredi 18 février 2009 Statut Membre Dernière intervention 15 octobre 2009
11 mai 2009 à 13:11
Ah oui ça a marché. Merci
0
Rejoignez-nous