首先要修正源代码的一些错误 以下两个地方需要改正: 1、 \cximage\cximage\ximatran.cpp(174) : error C2666: 'div ' : 2 overloads have similar conversions \vc\include\stdlib.h(508): could be 'ldiv_t div(long,long) ' d:\vs8\vc\include\stdlib.h(482): or 'div_t div(int,int) ' div的参数强制转换为long 就可以了 2、 for(int i=....) 在VS2005里面, for循环体里面定义 只在循环体内有效,所以会出现一些i 没有定义的问题 然后把所有生成的Lib最好都放到一个文件夹下,方便使用 我是放到 E:\lib\release E:\lib\debug 这是官方的帮助对在自己的工程中使用CxImage类库的说明: Project Settings |- C/C++ | |- Code Generation | | |- Use run-time library : Multithreaded DLL (must be the same for | | | all the linked libraries) | | |- Struct member alignment : must be the same for all the linked | | | libraries | |- Precompiled headers : not using precompiled headers | |- Preprocessor | |- Additional Include Directories: ..\cximage |- Link |- General |- Object/library modules: ../png/Debug/png.lib ../raw/Debug/libdcr.lib ../jpeg/Debug/jpeg.lib ../zlib/Debug/zlib.lib ../tiff/Debug/tiff.lib ../jasper/Debug/jasper.lib ../cximage/Debug/cximage.lib ...
imageDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CxImage::CxImage(unsigned long)" (??0CxImage@@QAE@K@Z)
image.obj : error LNK2001: unresolved external symbol "public: __thiscall CxImage::CxImage(class CxImage const &,bool,bool,bool)" (??0CxImage@@QAE@ABV0@_N11@Z)
imageDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CxImage::CxImage(class CxImage const &,bool,bool,bool)" (??0CxImage@@QAE@ABV0@_N11@Z)
Debug/image.exe : fatal error LNK1120: 19 unresolved externals
Error executing link.exe.image.exe - 39 error(s), 0 warning(s)很多的链接错误,我只是在工程中包含了ximage.h和xfile.h两个头文件,其他的源代码都是用的编译器自己生成的!相应的库文件在Cximage中已经经过了编译,但是在编译一个demo中的文件的时侯无法通过编译显示一个错误 can't open lib file "mfc42u.lib"
链接器
¦- 输入
¦- 附加依赖项------这里加上Cximage产生的lib文件
encode
先读按bmp格式读入一幅图片,再将它解释成jpg图片
然后:
CxImage imag;
imag.Load("C:\\txt.bmp",CXIMAGE_FORMAT_BMP);
imag.save("C:\\txt.jpg", CXIMAGE_FORMAT_JPG);即可编译一个demo中的文件的时侯无法通过编译显示一个错误 can't open lib file "这是因为你的机器没有装unicode编码的lib文件,在安装文件中找到mfc42u.lib文件放入相应目录即可。
\cximage\cximage\ximatran.cpp(174) : error C2666: 'div ' : 2 overloads have similar conversions
\vc\include\stdlib.h(508): could be 'ldiv_t div(long,long) '
d:\vs8\vc\include\stdlib.h(482): or 'div_t div(int,int) ' div的参数强制转换为long 就可以了 2、 for(int i=....) 在VS2005里面, for循环体里面定义 只在循环体内有效,所以会出现一些i 没有定义的问题
然后把所有生成的Lib最好都放到一个文件夹下,方便使用 我是放到 E:\lib\release
E:\lib\debug 这是官方的帮助对在自己的工程中使用CxImage类库的说明: Project Settings
|- C/C++
| |- Code Generation
| | |- Use run-time library : Multithreaded DLL (must be the same for
| | | all the linked libraries)
| | |- Struct member alignment : must be the same for all the linked
| | | libraries
| |- Precompiled headers : not using precompiled headers
| |- Preprocessor
| |- Additional Include Directories: ..\cximage
|- Link
|- General
|- Object/library modules: ../png/Debug/png.lib
../raw/Debug/libdcr.lib
../jpeg/Debug/jpeg.lib
../zlib/Debug/zlib.lib
../tiff/Debug/tiff.lib
../jasper/Debug/jasper.lib
../cximage/Debug/cximage.lib ...
首先: 选项->工具->项目和解决方案->VC++目录 库文件: 增加 : E:\lib\release E:\lib\debug 包含文件: 增加: (your CxImage dir)\CxImage
然后在你的工程中: 项目->属性->配置属性->链接器->输入->附加依赖项 : 增加: cximage.lib jpeg.lib png.lib tiff.lib j2k.lib jasper.lib jbig.lib zlib.lib 在 项目->属性->配置属性->常规 MFC使用: 在共享DLL中使用MFC 字符集: 使用多字节字符集 在项目->属性->配置属性->C/C++->代码生成 运行时库 : /MD
结构成员对齐: 16字节 预编译头:不使用预编译头 OK,这样子,就可以开始使用CxImage啦
Creating library Debug/Image.lib and object Debug/Image.exp
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_cleanup_dcraw
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _htons@4
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_flip_index
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_gamma_lut
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_stretch
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_convert_to_rgb
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_fuji_rotate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_recover_highlights
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_blend_highlights
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_median_filter
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_ahd_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_ppg_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_vng_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_lin_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_pre_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_scale_colors
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_subtract
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_bad_pixels
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_remove_zeroes
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_merror
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_kodak_ycbcr_load_raw
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_identify
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_parse_command_line_options
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_init_dcraw
Debug/Image.exe : fatal error LNK1120: 24 unresolved externals
Creating library Debug/Image.lib and object Debug/Image.exp
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_cleanup_dcraw
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _htons@4
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_flip_index
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_gamma_lut
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_stretch
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_convert_to_rgb
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_fuji_rotate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_recover_highlights
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_blend_highlights
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_median_filter
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_ahd_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_ppg_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_vng_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_lin_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_pre_interpolate
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_scale_colors
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_subtract
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_bad_pixels
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_remove_zeroes
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_merror
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_kodak_ycbcr_load_raw
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_identify
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_parse_command_line_options
cximage.lib(ximaraw.obj) : error LNK2001: unresolved external symbol _dcr_init_dcraw
Debug/Image.exe : fatal error LNK1120: 24 unresolved externals
编译demo是在link lib 下加上这个就行了