天天看點

Ubuntu16.04 編譯出錯c++: internal compiler error: Killed (program cc1plus)

最近在使用github上的一個模拟器,需要自己對其中檔案進行make編譯。但是中間遇到了不知道多少個錯誤,吐血。想了想還是記錄一下,

錯誤

compiling moc/moc_qwt_plot_panner.cpp
compiling moc/moc_qwt_plot_picker.cpp
compiling moc/moc_qwt_plot_zoomer.cpp
compiling moc/moc_qwt_slider.cpp
compiling moc/moc_qwt_scale_widget.cpp
{standard input}: Assembler messages:
{standard input}:4145: Warning: end of file in string; '"' inserted
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
Makefile:139809: recipe for target 'obj/qrc_qgcresources.o' failed
make[1]: *** [obj/qrc_qgcresources.o] Error 4
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/emma/ub-anc/build-emulator/qgc_gui'
Makefile:43: recipe for target 'sub-qgc_gui-make_first-ordered' failed
make: *** [sub-qgc_gui-make_first-ordered] Error 2
           

解決方法

google了各種辦法,發現應該是記憶體不夠,ubuntu的make指令好像比較吃記憶體。

  1. 嘗試用swap
  • check系統中swap的配置
  • 檢視多少可用的swap以及memory
$ sudo swapon --show
$ free -h
           
Ubuntu16.04 編譯出錯c++: internal compiler error: Killed (program cc1plus)
  • check 可用的磁盤空間
$ df -h
           
Ubuntu16.04 編譯出錯c++: internal compiler error: Killed (program cc1plus)
  • 建立一個2G的swap file
$ sudo fallocate -l 2G /swapfile 
           
  • 驗證建立的swapfile是否正确
$ ls -lh /swapfile
           
  • 修改檔案權限,隻能被root通路
$ sudo chmod 600 /swapfile
$ ls -lh /swapfile
           
  • 标記該檔案空間為swap space
$ sudo mkswap /swapfile
           

詳情見下圖:

Ubuntu16.04 編譯出錯c++: internal compiler error: Killed (program cc1plus)

到這裡,然後再重新執行qmake與make指令,就成功啦。

Note1 : ** swap的開啟以及更多相關指令請參考:**

How To Add Swap Space on Ubuntu 16.04

Note2:該編譯錯誤參考連結:

luascript.cpp.o Warning: end of file in string Ubuntu 14.04x64 - SOLVED #1408

繼續閱讀