PDA

Visualizza la versione completa : [c++] conflitto tra librerie


Infernal
17-09-2008, 21:35
Sto scrivendo un programma in cui uso la libreria Freeimage, il problema è che nel programma devo includere anche windows.h, e quando compilo mi vanno in confilitto (credo) gli header di freeimage con quelli di windows.h

come posso fare?

ps: la libreria windows.h la uso solo per la Sleep()... se c'è un altro modo per fare attendere il programma tolgo windows.h e uso quello....

grazie a tutti!

gli errori sono questi:


In file included from N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windows.h:48,
from C:\Programmazione\DanceimageWX\DanceimageWXMain.cp p:47:
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windef.h:229: error: conflicting declaration 'typedef long unsigned int DWORD'
C:\Programmazione\DanceimageWX\FreeImage.h:156: error: 'DWORD' has a previous declaration as `typedef uint32_t DWORD'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windef.h:229: error: declaration of `typedef long unsigned int DWORD'
C:\Programmazione\DanceimageWX\FreeImage.h:156: error: conflicts with previous declaration `typedef uint32_t DWORD'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windef.h:229: error: declaration of `typedef long unsigned int DWORD'
C:\Programmazione\DanceimageWX\FreeImage.h:156: error: conflicts with previous declaration `typedef uint32_t DWORD'
In file included from N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windef.h:253,
from N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windows.h:48,
from C:\Programmazione\DanceimageWX\DanceimageWXMain.cp p:47:
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winnt.h:79: error: conflicting declaration 'typedef long int LONG'
C:\Programmazione\DanceimageWX\FreeImage.h:157: error: 'LONG' has a previous declaration as `typedef int32_t LONG'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winnt.h:79: error: declaration of `typedef long int LONG'
C:\Programmazione\DanceimageWX\FreeImage.h:157: error: conflicts with previous declaration `typedef int32_t LONG'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winnt.h:79: error: declaration of `typedef long int LONG'
C:\Programmazione\DanceimageWX\FreeImage.h:157: error: conflicts with previous declaration `typedef int32_t LONG'
In file included from N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windows.h:52,
from C:\Programmazione\DanceimageWX\DanceimageWXMain.cp p:47:
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1360: error: redefinition of `struct tagRGBTRIPLE'
C:\Programmazione\DanceimageWX\FreeImage.h:186: error: previous definition of `struct tagRGBTRIPLE'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1364: error: conflicting declaration 'typedef int RGBTRIPLE'
C:\Programmazione\DanceimageWX\FreeImage.h:196: error: 'RGBTRIPLE' has a previous declaration as `typedef struct tagRGBTRIPLE RGBTRIPLE'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1364: error: declaration of `typedef int RGBTRIPLE'
C:\Programmazione\DanceimageWX\FreeImage.h:196: error: conflicts with previous declaration `typedef struct tagRGBTRIPLE RGBTRIPLE'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1364: error: declaration of `typedef int RGBTRIPLE'
C:\Programmazione\DanceimageWX\FreeImage.h:196: error: conflicts with previous declaration `typedef struct tagRGBTRIPLE RGBTRIPLE'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1379: error: redefinition of `struct tagBITMAPINFOHEADER'
C:\Programmazione\DanceimageWX\FreeImage.h:204: error: previous definition of `struct tagBITMAPINFOHEADER'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1391: error: conflicting declaration 'typedef int BITMAPINFOHEADER'
C:\Programmazione\DanceimageWX\FreeImage.h:216: error: 'BITMAPINFOHEADER' has a previous declaration as `typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1391: error: declaration of `typedef int BITMAPINFOHEADER'
C:\Programmazione\DanceimageWX\FreeImage.h:216: error: conflicts with previous declaration `typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1391: error: declaration of `typedef int BITMAPINFOHEADER'
C:\Programmazione\DanceimageWX\FreeImage.h:216: error: conflicts with previous declaration `typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1391: error: conflicting declaration 'typedef int*PBITMAPINFOHEADER'
C:\Programmazione\DanceimageWX\FreeImage.h:216: error: 'PBITMAPINFOHEADER' has a previous declaration as `typedef struct tagBITMAPINFOHEADER*PBITMAPINFOHEADER'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1391: error: declaration of `typedef int*PBITMAPINFOHEADER'
C:\Programmazione\DanceimageWX\FreeImage.h:216: error: conflicts with previous declaration `typedef struct tagBITMAPINFOHEADER*PBITMAPINFOHEADER'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1391: error: declaration of `typedef int*PBITMAPINFOHEADER'
C:\Programmazione\DanceimageWX\FreeImage.h:216: error: conflicts with previous declaration `typedef struct tagBITMAPINFOHEADER*PBITMAPINFOHEADER'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1392: error: redefinition of `struct tagRGBQUAD'
C:\Programmazione\DanceimageWX\FreeImage.h:173: error: previous definition of `struct tagRGBQUAD'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1397: error: conflicting declaration 'typedef int RGBQUAD'
C:\Programmazione\DanceimageWX\FreeImage.h:184: error: 'RGBQUAD' has a previous declaration as `typedef struct tagRGBQUAD RGBQUAD'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1397: error: declaration of `typedef int RGBQUAD'
C:\Programmazione\DanceimageWX\FreeImage.h:184: error: conflicts with previous declaration `typedef struct tagRGBQUAD RGBQUAD'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1397: error: declaration of `typedef int RGBQUAD'
C:\Programmazione\DanceimageWX\FreeImage.h:184: error: conflicts with previous declaration `typedef struct tagRGBQUAD RGBQUAD'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1398: error: redefinition of `struct tagBITMAPINFO'
C:\Programmazione\DanceimageWX\FreeImage.h:218: error: previous definition of `struct tagBITMAPINFO'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1401: error: conflicting declaration 'typedef int BITMAPINFO'
C:\Programmazione\DanceimageWX\FreeImage.h:221: error: 'BITMAPINFO' has a previous declaration as `typedef struct tagBITMAPINFO BITMAPINFO'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1401: error: declaration of `typedef int BITMAPINFO'
C:\Programmazione\DanceimageWX\FreeImage.h:221: error: conflicts with previous declaration `typedef struct tagBITMAPINFO BITMAPINFO'
N:/Programmi/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1401: error: declaration of `typedef int BITMAPINFO'
C:\Programmazione\DanceimageWX\FreeImage.h:221: error: conflicts with previous declaration `typedef struct tagBITMAPINFO BITMAPINFO'

pallinopinco
17-09-2008, 21:41
Cerca nel forum, la soluzione è stata proposta qualche giorno fa.

Infernal
17-09-2008, 22:10
scusa se rompo... ma non trovo niente con la ricerca del forum... ti ricordi come si chimava il topic più o meno? :D :D thanks

pallinopinco
17-09-2008, 22:11
Cosa hai cercato?

Dovresti trovarlo facilmente visto che si tratta di una discussione alla quale TU hai partecipato.

Infernal
17-09-2008, 22:14
cose tipo:

conflitto librerie
freeimage e windows.h
freeimage
windows.h

io non mi ricordo di aver partecipato... cioè.. mi ricordo di quando mi hai detto di aggiungere il #define _WINDOWS_ ma l'ho aggiunto e lo fa lo stesso...

pallinopinco
17-09-2008, 22:30
L'hai aggiunto nel modo o nel punto sbagliato, io l'ho fatto e funziona perfettamente.

Questo è l'output del compilatore PRIMA della modifica:



c:\freeimage>g++ LoadFromMemory.cpp -L . -lfreeimage

In file included from LoadFromMemory.cpp:7:
FreeImage.h:156: error: conflicting declaration 'typedef uint32_t DWORD'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/windef.h:229: err
or: 'DWORD' has a previous declaration as 'typedef long unsigned int DWORD'
FreeImage.h:157: error: conflicting declaration 'typedef int32_t LONG'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/winnt.h:79: error
: 'LONG' has a previous declaration as 'typedef long int LONG'
FreeImage.h:173: error: redefinition of 'struct tagRGBQUAD'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1383: er
ror: previous definition of 'struct tagRGBQUAD'
FreeImage.h:184: error: invalid type in declaration before ';' token
FreeImage.h:184: error: conflicting declaration 'typedef int RGBQUAD'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1388: er
ror: 'RGBQUAD' has a previous declaration as 'typedef struct tagRGBQUAD RGBQUAD'

FreeImage.h:186: error: redefinition of 'struct tagRGBTRIPLE'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1351: er
ror: previous definition of 'struct tagRGBTRIPLE'
FreeImage.h:196: error: invalid type in declaration before ';' token
FreeImage.h:196: error: conflicting declaration 'typedef int RGBTRIPLE'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1355: er
ror: 'RGBTRIPLE' has a previous declaration as 'typedef struct tagRGBTRIPLE RGBT
RIPLE'
FreeImage.h:204: error: redefinition of 'struct tagBITMAPINFOHEADER'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1370: er
ror: previous definition of 'struct tagBITMAPINFOHEADER'
FreeImage.h:216: error: invalid type in declaration before ',' token
FreeImage.h:216: error: conflicting declaration 'typedef int BITMAPINFOHEADER'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1382: er
ror: 'BITMAPINFOHEADER' has a previous declaration as 'typedef struct tagBITMAPI
NFOHEADER BITMAPINFOHEADER'
FreeImage.h:216: error: conflicting declaration 'typedef int* PBITMAPINFOHEADER'

c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1382: er
ror: 'PBITMAPINFOHEADER' has a previous declaration as 'typedef struct tagBITMAP
INFOHEADER* PBITMAPINFOHEADER'
FreeImage.h:218: error: redefinition of 'struct tagBITMAPINFO'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1389: er
ror: previous definition of 'struct tagBITMAPINFO'
FreeImage.h:221: error: invalid type in declaration before ',' token
FreeImage.h:221: error: conflicting declaration 'typedef int BITMAPINFO'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1392: er
ror: 'BITMAPINFO' has a previous declaration as 'typedef struct tagBITMAPINFO BI
TMAPINFO'
FreeImage.h:221: error: conflicting declaration 'typedef int* PBITMAPINFO'
c:\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/../../../../include/wingdi.h:1392: er
ror: 'PBITMAPINFO' has a previous declaration as 'typedef struct tagBITMAPINFO*
PBITMAPINFO'


Questo è l'output DOPO la modifica:



c:\freeimage>g++ LoadFromMemory.cpp -L . -lfreeimage

c:\freeimage>dir
Il volume nell'unità C è PallinoPinco
Numero di serie del volume: 0E24-1543

Directory di c:\freeimage

17/09/2008 22.26 <DIR> .
17/09/2008 22.26 <DIR> ..
17/09/2008 22.26 104.865 a.exe
17/12/2007 14.36 171.492 freeimage.a
27/07/2008 17.41 2.084.864 FreeImage.dll
17/09/2008 22.26 50.324 FreeImage.h
27/07/2008 17.41 58.886 FreeImage.lib
17/12/2007 14.36 171.492 libfreeimage.a
17/09/2008 22.26 2.057 LoadFromMemory.cpp
17/09/2008 22.26 3.163 result
8 File 2.647.143 byte
2 Directory 23.756.374.016 byte disponibili

c:\freeimage>


Come puoi vedere è stato creato l'eseguibile dell'esempio LoadFromMemory.cpp al quale ho aggiunto un #include <windows.h>.



io non mi ricordo di aver partecipato


Ci sono 2 Infernal in questo forum o hai una doppia personalità? :)

Infernal
17-09-2008, 22:47
risolto.. dovevo prima includere windows.h e poi freeimage.h...... ma perchè? hce differenza c'è nell'includere prima uno e poi l'altro?


Originariamente inviato da pallinopinco
Ci sono 2 Infernal in questo forum o hai una doppia personalità? :)

A volte capita che mi trasformo e non mi ricordo cosa ho fatto nell'altra vita.... ma dopo un po' passa...
:D :D

grazie mille... (come sempre)

oregon
17-09-2008, 22:51
Originariamente inviato da Infernal
... nell'includere prima uno e poi l'altro?

Beh ... la compilazione e' un processo sequenziale ...

Se un tipo di dato o una costante viene definita dal primo include e usato nel secondo, al contrario, non pensi che ci possano essere problemi?

Infernal
18-09-2008, 14:27
sisi... su questo sono d'accordo.. ma visto che freeimage non ha bisogno di windows.h non penso utilizzi tipi o funzioni definiti in windows.h...

Loading