Ubuntu 环境 FreeImage 编译安装
Posted coffee tea or me
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu 环境 FreeImage 编译安装相关的知识,希望对你有一定的参考价值。
0. 下载源码到本地
freeImage源码包下载网站
wget http://downloads.sourceforge.net/freeimage/FreeImage3170.zip unzip FreeImage3170.zip cd FreeImage make
1. 编译时会出现的问题
1.1 错误信息如下
Source/LibRawLite/./internal/dcraw_common.cpp: In member function ‘void LibRaw::vng_interpolate()’: Source/LibRawLite/./internal/dcraw_common.cpp:4559:3: error: narrowing conversion of ‘128’ from ‘int’ to ‘signed char’ inside { } [-Wnarrowing] }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 }; ^ Source/LibRawLite/./internal/dcraw_common.cpp:4559:3: error: narrowing conversion of ‘136’ from ‘int’ to ‘signed char’ inside { } [-Wnarrowing] Source/LibRawLite/./internal/dcraw_common.cpp:4559:3: error: narrowing conversion of ‘128’ from ‘int’ to ‘signed char’ inside { } [-Wnarrowing] Source/LibRawLite/./internal/dcraw_common.cpp:4559:3: error: narrowing conversion of ‘136’ from ‘int’ to ‘signed char’ inside { } [-Wnarrowing] Source/LibRawLite/./internal/dcraw_common.cpp:4559:3: error: narrowing conversion of ‘128’ from ‘int’ to ‘signed char’ inside { } [-Wnarrowing]
对应源码定位
4536 static const signed char *cp, terms[] = { 4537 -2,-2,+0,-1,0,0x01, -2,-2,+0,+0,1,0x01, -2,-1,-1,+0,0,0x01, 4538 -2,-1,+0,-1,0,0x02, -2,-1,+0,+0,0,0x03, -2,-1,+0,+1,1,0x01, 4539 -2,+0,+0,-1,0,0x06, -2,+0,+0,+0,1,0x02, -2,+0,+0,+1,0,0x03, 4540 -2,+1,-1,+0,0,0x04, -2,+1,+0,-1,1,0x04, -2,+1,+0,+0,0,0x06, 4541 -2,+1,+0,+1,0,0x02, -2,+2,+0,+0,1,0x04, -2,+2,+0,+1,0,0x04, 4542 -1,-2,-1,+0,0,0x80, -1,-2,+0,-1,0,0x01, -1,-2,+1,-1,0,0x01, 4543 -1,-2,+1,+0,1,0x01, -1,-1,-1,+1,0,0x88, -1,-1,+1,-2,0,0x40, 4544 -1,-1,+1,-1,0,0x22, -1,-1,+1,+0,0,0x33, -1,-1,+1,+1,1,0x11, 4545 -1,+0,-1,+2,0,0x08, -1,+0,+0,-1,0,0x44, -1,+0,+0,+1,0,0x11, 4546 -1,+0,+1,-2,1,0x40, -1,+0,+1,-1,0,0x66, -1,+0,+1,+0,1,0x22, 4547 -1,+0,+1,+1,0,0x33, -1,+0,+1,+2,1,0x10, -1,+1,+1,-1,1,0x44, 4548 -1,+1,+1,+0,0,0x66, -1,+1,+1,+1,0,0x22, -1,+1,+1,+2,0,0x10, 4549 -1,+2,+0,+1,0,0x04, -1,+2,+1,+0,1,0x04, -1,+2,+1,+1,0,0x04, 4550 +0,-2,+0,+0,1,0x80, +0,-1,+0,+1,1,0x88, +0,-1,+1,-2,0,0x40, 4551 +0,-1,+1,+0,0,0x11, +0,-1,+2,-2,0,0x40, +0,-1,+2,-1,0,0x20, 4552 +0,-1,+2,+0,0,0x30, +0,-1,+2,+1,1,0x10, +0,+0,+0,+2,1,0x08, 4553 +0,+0,+2,-2,1,0x40, +0,+0,+2,-1,0,0x60, +0,+0,+2,+0,1,0x20, 4554 +0,+0,+2,+1,0,0x30, +0,+0,+2,+2,1,0x10, +0,+1,+1,+0,0,0x44, 4555 +0,+1,+1,+2,0,0x10, +0,+1,+2,-1,1,0x40, +0,+1,+2,+0,0,0x60, 4556 +0,+1,+2,+1,0,0x20, +0,+1,+2,+2,0,0x10, +1,-2,+1,+0,0,0x80, 4557 +1,-1,+1,+1,0,+1,+0,+1,+2,0,0x08, +1,+0,+2,-1,0,0x40, 4558 +1,+0,+2,+1,0,0x10 4559 }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 };
解决方案,修改成如下所示
4536 static const signed char *cp, terms[] = { 4537 -2,-2,+0,-1,0,(char)0x01, -2,-2,+0,+0,1,(char)0x01, -2,-1,-1,+0,0,(char)0x01, 4538 -2,-1,+0,-1,0,(char)0x02, -2,-1,+0,+0,0,(char)0x03, -2,-1,+0,+1,1,(char)0x01, 4539 -2,+0,+0,-1,0,(char)0x06, -2,+0,+0,+0,1,(char)0x02, -2,+0,+0,+1,0,(char)0x03, 4540 -2,+1,-1,+0,0,(char)0x04, -2,+1,+0,-1,1,(char)0x04, -2,+1,+0,+0,0,(char)0x06, 4541 -2,+1,+0,+1,0,(char)0x02, -2,+2,+0,+0,1,(char)0x04, -2,+2,+0,+1,0,(char)0x04, 4542 -1,-2,-1,+0,0,(char)0x80, -1,-2,+0,-1,0,(char)0x01, -1,-2,+1,-1,0,(char)0x01, 4543 -1,-2,+1,+0,1,(char)0x01, -1,-1,-1,+1,0,(char)0x88, -1,-1,+1,-2,0,(char)0x40, 4544 -1,-1,+1,-1,0,(char)0x22, -1,-1,+1,+0,0,(char)0x33, -1,-1,+1,+1,1,(char)0x11, 4545 -1,+0,-1,+2,0,(char)0x08, -1,+0,+0,-1,0,(char)0x44, -1,+0,+0,+1,0,(char)0x11, 4546 -1,+0,+1,-2,1,(char)0x40, -1,+0,+1,-1,0,(char)0x66, -1,+0,+1,+0,1,(char)0x22, 4547 -1,+0,+1,+1,0,(char)0x33, -1,+0,+1,+2,1,(char)0x10, -1,+1,+1,-1,1,(char)0x44, 4548 -1,+1,+1,+0,0,(char)0x66, -1,+1,+1,+1,0,(char)0x22, -1,+1,+1,+2,0,(char)0x10, 4549 -1,+2,+0,+1,0,(char)0x04, -1,+2,+1,+0,1,(char)0x04, -1,+2,+1,+1,0,(char)0x04, 4550 +0,-2,+0,+0,1,(char)0x80, +0,-1,+0,+1,1,(char)0x88, +0,-1,+1,-2,0,(char)0x40, 4551 +0,-1,+1,+0,0,(char)0x11, +0,-1,+2,-2,0,(char)0x40, +0,-1,+2,-1,0,(char)0x20, 4552 +0,-1,+2,+0,0,(char)0x30, +0,-1,+2,+1,1,(char)0x10, +0,+0,+0,+2,1,(char)0x08, 4553 +0,+0,+2,-2,1,(char)0x40, +0,+0,+2,-1,0,(char)0x60, +0,+0,+2,+0,1,(char)0x20, 4554 +0,+0,+2,+1,0,(char)0x30, +0,+0,+2,+2,1,(char)0x10, +0,+1,+1,+0,0,(char)0x44, 4555 +0,+1,+1,+2,0,(char)0x10, +0,+1,+2,-1,1,(char)0x40, +0,+1,+2,+0,0,(char)0x60, 4556 +0,+1,+2,+1,0,(char)0x20, +0,+1,+2,+2,0,(char)0x10, +1,-2,+1,+0,0,(char)0x80, 4557 +1,-1,+1,+1,0,+1,+0,+1,+2,0,(char)0x08, +1,+0,+2,-1,0,(char)0x40, 4558 +1,+0,+2,+1,0,(char)0x10 4559 }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 };
1.2 错误信息提示
Source/LibRawLite/./internal/dcraw_common.cpp:7826:97: error: call of overloaded ‘powf64(int, int)’ is ambiguous 10*(table_buf[iLensData+9]>>2) * powf64(4, (table_buf[iLensData+9] & 0x03)-2);
源码定位
7824 if (table_buf[iLensData+9] && (fabs(imgdata.lens.makernotes.CurFocal) < 0.1f)) 7825 imgdata.lens.makernotes.CurFocal = 10*(table_buf[iLensData+9]>>2) * powf64(4, (table_buf[iLensData+9] & 0x03)-2);
解决方案
7824 if (table_buf[iLensData+9] && (fabs(imgdata.lens.makernotes.CurFocal) < 0.1f)) 7825 imgdata.lens.makernotes.CurFocal = 10*(table_buf[iLensData+9]>>2) * powf64(4.f, (table_buf[iLensData+9] & 0x03)-2);
1.3 上述问题修改完成后再次进行编译
make
2. 成功后在Dist文件夹下会生成静态链接、动态链接以及头文件
#============================================================================================ # CMakeLists.txt #============================================================================================ set(FreeImage_INCLUDE_DIR "/path/to/FreeImage-3.17.0/Dist") include_directories( ${FreeImage_INCLUDE_DIRS} ) find_library(FreeImage_LIBS freeimage-3.17.0 ${FreeImage_DIR}) target_link_libraries( executable_name ${FreeImage_LIBS} )
参考资料
[1] FreeImage编译及遇到问题解决 https://www.bbsmax.com/A/gVdnQrN5Wl/
以上是关于Ubuntu 环境 FreeImage 编译安装的主要内容,如果未能解决你的问题,请参考以下文章