qt mingw编译vtk,File too big/too many sections

使用qt5.10编译vtk,cmake选择release版本时,编译正常通过。但程序链接时,debug版本无法运行,报错:Must construct a QApplication before a QWidget。所以只能编译debug版的vtk,结果出现File too big/too many sections错误:

出现此错误的原因是obj文件太大了,通过查找资料,发现obj文件过大时,需要配置选项: -Wa,-mbig-obj

但通过命令行直接修改gcc参数的方式进行了实验,无效。发现在链接:
中说到,You've probably hit a hard memory limit such that the object image is
greater than 2GB.  There is no work around for a hard limit other than
to reduce the size of the object is some fashion.
所以应该无法通过配置实现debug版本编译了,于是考虑缩小obj文件的大小,打算将一个obj分为两个,分别编译。将出错的文件:VTK-8.2.0\Common\Core\vtkDataArray.cxx分为两个文件,将ComputeFiniteScalarRange、ComputeFiniteVectorRange两个函数(及其使用的struct定义复制一遍)移动到vtkDataArray1.cxx文件中,并修改cmakelist,添加了vtkDataArray1.cxx,再进行编译,就解决了此问题。
posted on 2019-09-08 14:52  yangzifb  阅读(3030)  评论(0)    收藏  举报