FreeImage3180
解决方案:
找到如下文件:
FreeImage3180/FreeImage/Source/OpenEXR/Imath/ImathVec.h
FreeImage3180/FreeImage/Source/OpenEXR/Imath/ImathVec.cpp
FreeImage3180/FreeImage/Source/OpenEXR/Imath/ImathMatrix.h
将函数的声明与实现的 throw 进行注释或删除即可:
//原代码:
const Vec2 & normalizeExc () throw (IEX_NAMESPACE::MathExc);
// 修改后:
const Vec2 & normalizeExc ();
//原代码:
Vec4<short>::normalizedExc () const throw (IEX_NAMESPACE::MathExc)
// 修改后:
Vec4<short>::normalizedExc () const //throw (IEX_NAMESPACE::MathExc)
原因:
在C++11及以后的版本中,动态异常规格(dynamic exception specifications,也就是函数声明后的throw(…)部分)已经被废弃,并在C++17中完全移除。
因此,编译包含这种动态异常规格的代码时,编译器会报错。
下面为报错内容, 可忽略:
make -f Makefile.gnu
make[1]: Entering directory '/home/x/depends/FreeImage3180/FreeImage'
g++ -O3 -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy -D__ANSI__ -I. -ISource -ISource/Metadata -ISource/FreeImageToolkit -ISource/LibJPEG -ISource/LibPNG -ISource/LibTIFF4 -ISource/ZLib -ISource/LibOpenJPEG -ISource/OpenEXR -ISource/OpenEXR/Half -ISource/OpenEXR/Iex -ISource/OpenEXR/IlmImf -ISource/OpenEXR/IlmThread -ISource/OpenEXR/Imath -ISource/OpenEXR/IexMath -ISource/LibRawLite -ISource/LibRawLite/dcraw -ISource/LibRawLite/internal -ISource/LibRawLite/libraw -ISource/LibRawLite/src -ISource/LibWebP -ISource/LibJXR -ISource/LibJXR/common/include -ISource/LibJXR/image/sys -ISource/LibJXR/jxrgluelib -fPIC -c Source/FreeImage/PluginEXR.cpp -o Source/FreeImage/PluginEXR.o
In file included from Source/FreeImage/../OpenEXR/IlmImf/ImfHeader.h:51,
from Source/FreeImage/../OpenEXR/IlmImf/ImfOutputFile.h:46,
from Source/FreeImage/PluginEXR.cpp:33:
Source/OpenEXR/Imath/ImathVec.h:228:41: error: ISO C++17 does not allow dynamic exception specifications
228 | const Vec2 & normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:232:48: error: ISO C++17 does not allow dynamic exception specifications
232 | Vec2<T> normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:440:41: error: ISO C++17 does not allow dynamic exception specifications
440 | const Vec3 & normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:444:48: error: ISO C++17 does not allow dynamic exception specifications
444 | Vec3<T> normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:622:37: error: ISO C++17 does not allow dynamic exception specifications
622 | const Vec4 & normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:626:44: error: ISO C++17 does not allow dynamic exception specifications
626 | Vec4<T> normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:714:30: error: ISO C++17 does not allow dynamic exception specifications
714 | Vec2<short>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:723:37: error: ISO C++17 does not allow dynamic exception specifications
723 | Vec2<short>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:738:28: error: ISO C++17 does not allow dynamic exception specifications
738 | Vec2<int>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:747:35: error: ISO C++17 does not allow dynamic exception specifications
747 | Vec2<int>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:762:30: error: ISO C++17 does not allow dynamic exception specifications
762 | Vec3<short>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:771:37: error: ISO C++17 does not allow dynamic exception specifications
771 | Vec3<short>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:786:28: error: ISO C++17 does not allow dynamic exception specifications
786 | Vec3<int>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:795:35: error: ISO C++17 does not allow dynamic exception specifications
795 | Vec3<int>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:809:30: error: ISO C++17 does not allow dynamic exception specifications
809 | Vec4<short>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:818:37: error: ISO C++17 does not allow dynamic exception specifications
818 | Vec4<short>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:833:28: error: ISO C++17 does not allow dynamic exception specifications
833 | Vec4<int>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:842:35: error: ISO C++17 does not allow dynamic exception specifications
842 | Vec4<int>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:1212:26: error: ISO C++17 does not allow dynamic exception specifications
1212 | Vec2<T>::normalizeExc () throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:1249:33: error: ISO C++17 does not allow dynamic exception specifications
1249 | Vec2<T>::normalizedExc () const throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:1704:26: error: ISO C++17 does not allow dynamic exception specifications
1704 | Vec3<T>::normalizeExc () throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:1743:33: error: ISO C++17 does not allow dynamic exception specifications
1743 | Vec3<T>::normalizedExc () const throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:2109:26: error: ISO C++17 does not allow dynamic exception specifications
2109 | Vec4<T>::normalizeExc () throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:2150:33: error: ISO C++17 does not allow dynamic exception specifications
2150 | Vec4<T>::normalizedExc () const throw (IEX_NAMESPACE::MathExc)
| ^~~~~
In file included from Source/FreeImage/../OpenEXR/IlmImf/ImfXdr.h:108,
from Source/FreeImage/../OpenEXR/IlmImf/ImfGenericOutputFile.h:40,
from Source/FreeImage/../OpenEXR/IlmImf/ImfOutputFile.h:49,
from Source/FreeImage/PluginEXR.cpp:33:
Source/OpenEXR/Half/half.h: In constructor ‘half::half(float)’:
Source/OpenEXR/Half/half.h:462:22: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
462 | register int e = (x.i >> 23) & 0x000001ff;
| ^
Source/OpenEXR/Half/half.h:473:26: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
473 | register int m = x.i & 0x007fffff;
| ^
make[1]: *** [Makefile.gnu:64: Source/FreeImage/PluginEXR.o] Error 1
make[1]: Leaving directory '/home/x/depends/FreeImage3180/FreeImage'
make: *** [Makefile:21: default] Error 2
make -f Makefile.gnu
make[1]: Entering directory '/home/x/depends/FreeImage3180/FreeImage'
g++ -O3 -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy -D__ANSI__ -I. -ISource -ISource/Metadata -ISource/FreeImageToolkit -ISource/LibJPEG -ISource/LibPNG -ISource/LibTIFF4 -ISource/ZLib -ISource/LibOpenJPEG -ISource/OpenEXR -ISource/OpenEXR/Half -ISource/OpenEXR/Iex -ISource/OpenEXR/IlmImf -ISource/OpenEXR/IlmThread -ISource/OpenEXR/Imath -ISource/OpenEXR/IexMath -ISource/LibRawLite -ISource/LibRawLite/dcraw -ISource/LibRawLite/internal -ISource/LibRawLite/libraw -ISource/LibRawLite/src -ISource/LibWebP -ISource/LibJXR -ISource/LibJXR/common/include -ISource/LibJXR/image/sys -ISource/LibJXR/jxrgluelib -fPIC -c Source/FreeImage/PluginEXR.cpp -o Source/FreeImage/PluginEXR.o
In file included from Source/FreeImage/../OpenEXR/IlmImf/ImfHeader.h:51,
from Source/FreeImage/../OpenEXR/IlmImf/ImfOutputFile.h:46,
from Source/FreeImage/PluginEXR.cpp:33:
Source/OpenEXR/Imath/ImathVec.h:228:41: error: ISO C++17 does not allow dynamic exception specifications
228 | const Vec2 & normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:232:48: error: ISO C++17 does not allow dynamic exception specifications
232 | Vec2<T> normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:440:41: error: ISO C++17 does not allow dynamic exception specifications
440 | const Vec3 & normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:444:48: error: ISO C++17 does not allow dynamic exception specifications
444 | Vec3<T> normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:622:37: error: ISO C++17 does not allow dynamic exception specifications
622 | const Vec4 & normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:626:44: error: ISO C++17 does not allow dynamic exception specifications
626 | Vec4<T> normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:714:30: error: ISO C++17 does not allow dynamic exception specifications
714 | Vec2<short>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:723:37: error: ISO C++17 does not allow dynamic exception specifications
723 | Vec2<short>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:738:28: error: ISO C++17 does not allow dynamic exception specifications
738 | Vec2<int>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:747:35: error: ISO C++17 does not allow dynamic exception specifications
747 | Vec2<int>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:762:30: error: ISO C++17 does not allow dynamic exception specifications
762 | Vec3<short>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:771:37: error: ISO C++17 does not allow dynamic exception specifications
771 | Vec3<short>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:786:28: error: ISO C++17 does not allow dynamic exception specifications
786 | Vec3<int>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:795:35: error: ISO C++17 does not allow dynamic exception specifications
795 | Vec3<int>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:809:30: error: ISO C++17 does not allow dynamic exception specifications
809 | Vec4<short>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:818:37: error: ISO C++17 does not allow dynamic exception specifications
818 | Vec4<short>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:833:28: error: ISO C++17 does not allow dynamic exception specifications
833 | Vec4<int>::normalizeExc () throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:842:35: error: ISO C++17 does not allow dynamic exception specifications
842 | Vec4<int>::normalizedExc () const throw (IEX_NAMESPACE::MathExc);
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:1212:26: error: ISO C++17 does not allow dynamic exception specifications
1212 | Vec2<T>::normalizeExc () throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:1249:33: error: ISO C++17 does not allow dynamic exception specifications
1249 | Vec2<T>::normalizedExc () const throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:1704:26: error: ISO C++17 does not allow dynamic exception specifications
1704 | Vec3<T>::normalizeExc () throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:1743:33: error: ISO C++17 does not allow dynamic exception specifications
1743 | Vec3<T>::normalizedExc () const throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:2109:26: error: ISO C++17 does not allow dynamic exception specifications
2109 | Vec4<T>::normalizeExc () throw (IEX_NAMESPACE::MathExc)
| ^~~~~
Source/OpenEXR/Imath/ImathVec.h:2150:33: error: ISO C++17 does not allow dynamic exception specifications
2150 | Vec4<T>::normalizedExc () const throw (IEX_NAMESPACE::MathExc)
| ^~~~~
In file included from Source/FreeImage/../OpenEXR/IlmImf/ImfXdr.h:108,
from Source/FreeImage/../OpenEXR/IlmImf/ImfGenericOutputFile.h:40,
from Source/FreeImage/../OpenEXR/IlmImf/ImfOutputFile.h:49,
from Source/FreeImage/PluginEXR.cpp:33:
Source/OpenEXR/Half/half.h: In constructor ‘half::half(float)’:
Source/OpenEXR/Half/half.h:462:22: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
462 | register int e = (x.i >> 23) & 0x000001ff;
| ^
Source/OpenEXR/Half/half.h:473:26: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
473 | register int m = x.i & 0x007fffff;
| ^
make[1]: *** [Makefile.gnu:64: Source/FreeImage/PluginEXR.o] Error 1
make[1]: Leaving directory '/home/x/depends/FreeImage3180/FreeImage'
make: *** [Makefile:21: default] Error 2
token_enc.o Source/LibWebP/src/enc/tree_enc.o Source/LibWebP/src/enc/vp8l_enc.o Source/LibWebP/src/enc/webp_enc.o Source/LibWebP/src/mux/anim_encode.o Source/LibWebP/src/mux/muxedit.o Source/LibWebP/src/mux/muxinternal.o Source/LibWebP/src/mux/muxread.o Source/LibWebP/src/utils/bit_reader_utils.o Source/LibWebP/src/utils/bit_writer_utils.o Source/LibWebP/src/utils/color_cache_utils.o Source/LibWebP/src/utils/filters_utils.o Source/LibWebP/src/utils/huffman_encode_utils.o Source/LibWebP/src/utils/huffman_utils.o Source/LibWebP/src/utils/quant_levels_dec_utils.o Source/LibWebP/src/utils/quant_levels_utils.o Source/LibWebP/src/utils/random_utils.o Source/LibWebP/src/utils/rescaler_utils.o Source/LibWebP/src/utils/thread_utils.o Source/LibWebP/src/utils/utils.o Source/LibJXR/image/decode/decode.o Source/LibJXR/image/decode/JXRTranscode.o Source/LibJXR/image/decode/postprocess.o Source/LibJXR/image/decode/segdec.o Source/LibJXR/image/decode/strdec.o Source/LibJXR/image/decode/strdec_x86.o Source/LibJXR/image/decode/strInvTransform.o Source/LibJXR/image/decode/strPredQuantDec.o Source/LibJXR/image/encode/encode.o Source/LibJXR/image/encode/segenc.o Source/LibJXR/image/encode/strenc.o Source/LibJXR/image/encode/strenc_x86.o Source/LibJXR/image/encode/strFwdTransform.o Source/LibJXR/image/encode/strPredQuantEnc.o Source/LibJXR/image/sys/adapthuff.o Source/LibJXR/image/sys/image.o Source/LibJXR/image/sys/strcodec.o Source/LibJXR/image/sys/strPredQuant.o Source/LibJXR/image/sys/strTransform.o Source/LibJXR/jxrgluelib/JXRGlue.o Source/LibJXR/jxrgluelib/JXRGlueJxr.o Source/LibJXR/jxrgluelib/JXRGluePFC.o Source/LibJXR/jxrgluelib/JXRMeta.o -lstdc++
/usr/bin/ld: Source/LibJXR/image/encode/strenc.o: in function `StrIOEncInit':
strenc.c:(.text+0x1594): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
mkdir -p Dist
cp *.a Dist/
cp *.so Dist/
cp Source/FreeImage.h Dist/
make[1]: Leaving directory '/home/x/depends/FreeImage3180/FreeImage'
x@x:~/depends/FreeImage3180/FreeImage$
x@x:~/depends/FreeImage3180/FreeImage$
x@x:~/depends/FreeImage3180/FreeImage$
x@x:~/depends/FreeImage3180/FreeImage$
x@x:~/depends/FreeImage3180/FreeImage$ sudo name install
sudo: name: command not found
x@x:~/depends/FreeImage3180/FreeImage$ sudo make install
make -f Makefile.gnu install
make[1]: Entering directory '/home/x/depends/FreeImage3180/FreeImage'
install -d //usr/include //usr/lib
install -m 644 -o root -g root Source/FreeImage.h //usr/include
install -m 644 -o root -g root libfreeimage.a //usr/lib
install -m 755 -o root -g root libfreeimage-3.18.0.so //usr/lib
ln -sf libfreeimage-3.18.0.so //usr/lib/libfreeimage.so.3
ln -sf libfreeimage.so.3 //usr/lib/libfreeimage.so
make[1]: Leaving directory '/home/x/depends/FreeImage3180/FreeImage'
x@x:~/depends/FreeImage3180/FreeImage$