Toon posts:

[C++] error LNK2005

Pagina: 1
Acties:

Verwijderd

Topicstarter
Mijn probleem is dat ik een header wil gebruiken in twee source bestanden, maar ik krijg steeds foutmeldingen dat er iets twee keer wordt gedefinieerd. Ik heb al verschillende dingen geprobeerd(zie source), maar de fouten blijven komen. Is hier een oplossing voor of doe ik iets fout?


Header file: headerfile.h
code:
1
2
3
4
5
6
7
8
9
10
#ifndef HEADERFILE_H
#define HEADERFILE_H

#define INITGUID

#include <dplay8.h>

#pragma once

#endif /* HEADERFILE_H */

source file: test1.cpp
code:
1
#include "headerfile.h"

source file: test2.cpp
code:
1
2
3
4
5
#include "headerfile.h"

void main()
{
}

errors:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
test2.obj : error LNK2005: _CLSID_DP8SP_TCPIP already defined in test1.obj
test2.obj : error LNK2005: _CLSID_DP8SP_SERIAL already defined in test1.obj
test2.obj : error LNK2005: _CLSID_DP8SP_MODEM already defined in test1.obj
test2.obj : error LNK2005: _CLSID_DP8SP_IPX already defined in test1.obj
test2.obj : error LNK2005: _IID_IDirectPlay8Server already defined in test1.obj
test2.obj : error LNK2005: _IID_IDirectPlay8Peer already defined in test1.obj
test2.obj : error LNK2005: _IID_IDirectPlay8Client already defined in test1.obj
test2.obj : error LNK2005: _CLSID_DirectPlay8Server already defined in test1.obj
test2.obj : error LNK2005: _CLSID_DirectPlay8Peer already defined in test1.obj
test2.obj : error LNK2005: _CLSID_DirectPlay8Client already defined in test1.obj
test2.obj : error LNK2005: _IID_IDirectPlay8AddressIP already defined in test1.obj
test2.obj : error LNK2005: _IID_IDirectPlay8Address already defined in test1.obj
test2.obj : error LNK2005: _CLSID_DirectPlay8Address already defined in test1.obj

  • whoami
  • Registratie: December 2000
  • Laatst online: 21:34

https://fgheysels.github.io/


  • roelio
  • Registratie: Februari 2001
  • Niet online

roelio

fruitig, en fris.

multiple inclusions? :)

AMD Phenom II X4 // 8 GB DDR2 // SAMSUNG 830 SSD // 840 EVO SSD // Daar is Sinterklaas alweer!!


  • The End
  • Registratie: Maart 2000
  • Laatst online: 18:16

The End

!Beginning

en als je het zo doet:
code:
1
2
3
4
5
6
7
8
9
10
#ifndef HEADERFILE_H
#define HEADERFILE_H

#pragma once

#define INITGUID

#include <dplay8.h>

#endif /* HEADERFILE_H */

Verwijderd

Topicstarter
Heb ik allemaal al geprobeerd, zoals je kunt zien in de source.
en als je het zo doet:
Nee zo werkt het ook niet.

  • The End
  • Registratie: Maart 2000
  • Laatst online: 18:16

The End

!Beginning

Dit haal ik uit de MSDN:

"If you use uuid.lib in combination with other .lib files that define GUIDs (for example, oledb.lib and adsiid.lib). For example:
oledb.lib(oledb_i.obj) : error LNK2005: _IID_ITransactionObject
already defined in uuid.lib(go7.obj)
To fix, add /FORCE:MULTIPLE to the linker command line options, and make sure that uuid.lib is the first library referenced."

Misschien een oplossing

Verwijderd

Topicstarter
Ja dat werkt harstikke bedankt
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
LINK : warning LNK4075: ignoring /INCREMENTAL due to /FORCE specification
test2.obj : warning LNK4006: _CLSID_DP8SP_TCPIP already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _CLSID_DP8SP_SERIAL already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _CLSID_DP8SP_MODEM already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _CLSID_DP8SP_IPX already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _IID_IDirectPlay8Server already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _IID_IDirectPlay8Peer already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _IID_IDirectPlay8Client already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _CLSID_DirectPlay8Server already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _CLSID_DirectPlay8Peer already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _CLSID_DirectPlay8Client already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _IID_IDirectPlay8AddressIP already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _IID_IDirectPlay8Address already defined in test1.obj; second definition ignored
test2.obj : warning LNK4006: _CLSID_DirectPlay8Address already defined in test1.obj; second definition ignored
Debug/test1.exe : warning LNK4088: image being generated due to /FORCE option; image may not run

Ik krijg nu een "warning in plaats van een error".
Pagina: 1