error LNK2001: unresolved external symbol _WinMain@16
Bonjour vous tous ,
j'utilise un vieux visual studio C++ 5.0 pour creer mes ptits programmes ;
d'habitude tout marche bien mais là je sèche ...
QQ pourrait-il compiler ce projet et me dire ce qui ne va pas ou bien si ça
fonctionne chez lui ?!
c pas très long ,tout d'abord un header :
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 29 30 31 32
| #ifndef CMONBITMAP
#define CMONBITMAP
const int MINI_INFO_HEADER_SIZE=16;
const int FILE_HEADER_SIZE=14;
const int RGBQUAD_SIZE=4;
#include <windows.h>
#include <fstream>
#include <string>
using namespace std;
class CMonBitmap {
private :
BITMAPFILEHEADER* strctFileHeader;//
BITMAPINFOHEADER* strctInfoHeader;
BYTE* chRGBQuads;
BYTE* chBitmap;
int uNBQuad;// nombre de structures RGBQUAD
ifstream inputFile;
void setFileHeader(void);
void setInfoHeader(void);
void setBitmap(void);
public :
CMonBitmap(string);
~CMonBitmap();
int getNBColors(void) {return uNBQuad;}
};
#endif // CMONBITMAP |
puis le cpp correspondant :
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #include "bitmap.h"
CMonBitmap::CMonBitmap(string fileName) {
inputFile.open(fileName.c_str());// Ouverture du flux
setFileHeader();
setInfoHeader();
setBitmap();
inputFile.close();
}
CMonBitmap::~CMonBitmap() {
delete chBitmap;
delete chRGBQuads;
delete strctInfoHeader;
delete strctFileHeader;
}
void CMonBitmap::setFileHeader(void) {
strctFileHeader = new BITMAPFILEHEADER;
inputFile>>strctFileHeader->bfType;
inputFile>>strctFileHeader->bfSize;
inputFile>>strctFileHeader->bfReserved1;
inputFile>>strctFileHeader->bfReserved2;
inputFile>>strctFileHeader->bfOffBits;
}
void CMonBitmap::setInfoHeader(void) {
strctInfoHeader = new BITMAPINFOHEADER;
inputFile>>strctInfoHeader->biSize;
inputFile>>strctInfoHeader->biWidth;
inputFile>>strctInfoHeader->biHeight;
inputFile>>strctInfoHeader->biPlanes;
inputFile>>strctInfoHeader->biBitCount;
if(strctInfoHeader->biSize > MINI_INFO_HEADER_SIZE)//les autres champs sont présents
{
inputFile>>strctInfoHeader->biCompression;
inputFile>>strctInfoHeader->biSizeImage;
inputFile>>strctInfoHeader->biXPelsPerMeter;
inputFile>>strctInfoHeader->biYPelsPerMeter;
inputFile>>strctInfoHeader->biClrUsed;
inputFile>>strctInfoHeader->biClrImportant;
}
}
void CMonBitmap::setBitmap(void) {
int octetFinal = (strctFileHeader->bfSize - FILE_HEADER_SIZE - strctInfoHeader->biSize);
chRGBQuads = new BYTE[octetFinal];
for(int i=0;i<octetFinal;i++) inputFile>>chRGBQuads[i];
if((strctInfoHeader->biSize > MINI_INFO_HEADER_SIZE) && (strctInfoHeader->biClrUsed == 0))
{
switch(strctInfoHeader->biBitCount)
{
case 1:
uNBQuad = 2;
break;
case 4:
uNBQuad = 16;
break;
case 8:
uNBQuad = 256;
break;
case 24:
uNBQuad = 0;
break;
default: //erreur ?!?! (division par zéro)
uNBQuad = 1/(strctInfoHeader->biBitCount - strctInfoHeader->biBitCount);
break;
}
chBitmap = chRGBQuads + (uNBQuad * RGBQUAD_SIZE);
}
else if(strctInfoHeader->biClrUsed > 0) uNBQuad = strctInfoHeader->biClrUsed;
else 1/(strctInfoHeader->biBitCount - strctInfoHeader->biBitCount); // erreur !?!? (division par zéro)
} |
enfin main.cpp :
Code:
1 2 3 4 5 6 7 8 9 10
| #include <iostream>
#include "bitmap.h"
int main(void) {
CMonBitmap bitmap("fortLocke.bmp");
cout<<"nombre de couleurs : "<<bitmap.getNBColors()<<endl;
return 0;
} |
Voilà ; ce code est sensé ouvrir .bmp afin de stocker les informations le concernant dans une classe.
Sauf que j'obtient le message suivant au linkage :
Code:
1 2 3 4
| Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/bitmap.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe. |
Merci