Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I would like to use the CxImage library in DevC++. (convert bmp to jpg)

I added the .lib to Project -> Project Options -> Parameters -> Linker: CxImage.lib, jpeg.lib

My Code is:
C++
#include <windows.h>
#include "ximage.h"
#include "stdafx.h"
#pragma comment(lib,"CxImage.lib")
#pragma comment(lib,"jpeg.lib")


int main()
{
 CxImage image;

 // bmp -> jpg
 image.Load("d:\\image.bmp", CXIMAGE_FORMAT_BMP);
 if (image.IsValid())
 {
  if(!image.IsGrayScale()) image.IncreaseBpp(24);
  image.SetJpegQuality(70);
  image.Save("d:\\image.jpg",CXIMAGE_FORMAT_JPG);
 }

 // jpg -> bmp
 
    image.Load("d:\\image.jpg", CXIMAGE_FORMAT_JPG);
 if (image.IsValid())
 {
  if(!image.IsGrayScale()) image.IncreaseBpp(24);
  image.Save("d:\\image2.bmp",CXIMAGE_FORMAT_BMP);
 }


}
 // redimensionner + bmp -> jpg
 
    image.Load("d:\\image.bmp", CXIMAGE_FORMAT_BMP);
 if (image.IsValid())
 {
  image.Resample(1024/2,768/2,1,0);
  image.Save("d:\\imagesize.jpg",CXIMAGE_FORMAT_JPG);
 }

 return 1;
}


I got errores like these:
[Linker error] undefined reference to `CxImage::CxImage(unsigned long)'
[Linker error] undefined reference to `CxImage::Load(char const*, unsigned long)'
[Linker error] undefined reference to `CxImage::~CxImage()'
[Linker error] undefined reference to `CxImage::~CxImage()'




Also, if I delete the .lib in my proyect, and compile, gives the same error. It looks like the linker doesn't found the functions into the lib, or the lib is corrupted.


I found a code in: http://codes-sources.commentcamarche.net/source/22754-conversion-bmp-jpeg-avec-librairie-cximage where is the code with the .lib and the .exe (working okay).


Anyone could solve this problem? Thanks a lot guys
Posted
Comments
Richard MacCutchan 6-May-15 12:29pm    
Are you sure that CxImage.lib is in the correct directory for the linker to find it?
KarstenK 6-May-15 12:57pm    
It is bad style to hard code pathes.

As Richard says check that the libs are in the path. I bet they arent...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900