微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 Cygwin 构建 Assimp

如何解决使用 Cygwin 构建 Assimp

我想使用 cmake 和 cygwin 来构建 Assimp。

根据 cmake 文档,cmake 有 7 个 Makefile 生成器:

Borland Makefiles
MSYS Makefiles
MinGW Makefiles
NMake Makefiles
NMake Makefiles JOM
Unix Makefiles
Watcom WMake

但是没有任何用于 cygwin 的 Makefile 生成器。

如何使用 cygwin 构建 Assimp?

解决方法

在 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

以及使用 -O1 的建议来自
gcc string table overflow error during compilation

有效。
有了所有这些,我们可以:

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。