在 cygwin 上构建,strcasecmp 存在问题
/pub/tmp/assimp-5.0.1/include/assimp/StringComparison.h:146:14: error: ‘::strcasecmp’ has not been declared; did you mean ‘strncmp’?
146 | return ::strcasecmp(s1,s2);
| ^~~~~~~~~~
| strncmp
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html
这是由于 Cygwin 仍然将其视为扩展
第二个问题来自复杂的 C++ 模板
[ 37%] Building CXX object code/CMakeFiles/assimp.dir/Importer/IFC/IFCReaderGen1_2x3.cpp.o
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/as: CMakeFiles/assimp.dir/Importer/IFC/IFCReaderGen1_2x3.cpp.o: too many sections (88485)
/tmp/cc95KPdy.s: Assembler messages:
/tmp/cc95KPdy.s: Fatal error: can't write 180 bytes to section .text of CMakeFiles/assimp.dir/Importer/IFC/IFCReaderGen1_2x3.cpp.o: 'file too big'
我们可以从以下地址获取解决方案:
https://digitalkarabela.com/mingw-w64-how-to-fix-file-too-big-too-many-sections/
第三个问题是
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/as: CMakeFiles/assimp.dir/Importer/StepFile/StepFileGen1.cpp.o: section .xdata$_ZNSt11_Tuple_implILm1EJSt14default_deleteIN6Assimp8StepFile31draughting_callout_relationshipEEEE7_M_headERS5_: string table overflow at offset 10000005
/tmp/ccNl78l4.s: Assembler messages:
/tmp/ccNl78l4.s: Fatal error: can't close CMakeFiles/assimp.dir/Importer/StepFile/StepFileGen1.cpp.o: file too big
以及来自
gcc string table overflow error during compilation
的使用 -O1 的建议
有效。
有了它们,我们可以:
tar -xf assimp-5.0.1.tar.gz
cd assimp-5.0.1
cmake -DCMAKE_CXX_FLAGS="-D_GNU_SOURCE -Wa,-mbig-obj -O1" -DCMAKE_C_FLAGS="-D_GNU_SOURCE -Wa,-mbig-obj -O1" .
make
最后
....
[100%] Linking CXX executable ../bin/unit.exe
[100%] Built target unit