使用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,再進行編譯,就解決了此問題。