VMware+ubuntu+linux下载及安装(win10)--6. Ubuntu--pcl编译过程中出现的错误及解决办法

本文详细解析C++编译过程中的内部编译错误和虚拟内存耗尽问题,提供增加swap分区、调整VMware内存配置等解决方案,适用于内存资源有限的开发环境。

问题1. C++: internal compiler error: killed (program cc1plus)

在这里插入图片描述
原因是:系统没有交换分区,编译过程中内存memory不足,编译失败. (我的memory是2GB)
解决办法:

  1. 创建分区文件 $ sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
    count=bs*1024, bs是分区文件的大小,单位是M。 (count means the file size in kilobytes. you have to multiply the MBs by 1024. Example: 64MB -> 65536/ 128MB -> 131072)
  2. 生成swap文件系统 $ sudo mkswap /swapfile
  3. 激活swap文件: $ sudo swapon /swapfile
  4. 重新编译:
$ cd pcl
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
  1. 编译成功后删除swapfile:
$ sudo swapoff /swapfile
$ sudo rm /swapfile

问题2. virtual memory exhausted: cannot allocate memory在这里插入图片描述

原因:没有设置swap大小或设置内存太小, 此处我的原因是没有设置swap大小
可以输入 $ free -m 查看memory 和swap
在这里插入图片描述
swap大小不够的话,可以通过$ sudo dd if=/dev/zero of=swapfile bs=1M count=4084 扩大
在这里插入图片描述
在这里插入图片描述
这里出现text file busy 是因为swapfile 已经存在且激活,如需扩大swapfile大小,可关闭并删除此前swapfile后新建swapfile.

$ sudo swapoff /swapfile
$ sudo rm /swapfile
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=4084
$ sudo mkswap /swapfile
$ sudo swapon /swapfile

如果是因为memory太小,先把ubuntu 关掉,在VMware里面更改ubuntu的设置,如下:
在这里插入图片描述
memory设为4G或更高
在这里插入图片描述
另外注意下面,计划分配多少MB给graphics memory,可设置可不设置,一般用推荐

问题三

在创建分区的时候出现:
在这里插入图片描述
原因是:可能已经有/swapfile打开了,不能重复打开
先看下是否swapfile已经打开了:
sudo swapon --show
在这里插入图片描述
如果已经打开,要先把swapfile 关掉并删除:
sudo swapoff -a
sudo rm /swapfile
之后重复问题一的解决步骤

问题四

在编译到43%的时候,一直出现错误“virtual memory exhausted: cannot allocate memory”,
为什么至今还不知道,
之前设置的memory=2G, 768M for graphics memory,
现在改成了momory=4G, 1G for graphic memory, swapfile: bs=1M, count=4084, 会出现没有空间可用,选择了ignore,没有理它。
43%的坎过去了,看后续还有没有其他错误,应该就是memory设置的太小。
到87%出现的问题:
在这里插入图片描述
猜测应该是内存不够
把swapfile关掉,再重新make一个,因为原来已经编译好的包再次编译的时候不会重复编译,就不会占用空间了,再重新make swapfile的话,就是for 剩下的15%内容的编译
在这里插入图片描述
难道还要把memory扩大到8G??
现在的配置
在这里插入图片描述
还是会出现同样的问题
那么将memory扩大到8G
扩大到8G还是有问题
在这里插入图片描述
可能是swapfile 没开,把swapfile打开后,
还是一样的问题
有人说是tmp的问题:
https://www.cnblogs.com/youxin/p/5116219.html
https://www.cnblogs.com/hahawgp/p/3601942.html
但是更改了后还是不行,
在这里插入图片描述
还是不行
最后把memory=16G, store=60G, 然后…就编译成功了,之前memory=8G, store=40G的时候都编译不成功。
编译完后63.1G还剩49.9G

问题五
‘fabs’ was not declared in this scope
在这里插入图片描述
这个问题不知道怎么解决,应该是版本不对

ii udev 249.11-0ubuntu3.16 amd64 /dev/ and hotplug management daemon ii udisks2 2.9.4-1ubuntu2.2 amd64 D-Bus service to access and manipulate storage devices ii ufw 0.36.1-4ubuntu0.1 all program for managing a Netfilter firewall ii unattended-upgrades 2.8ubuntu1 all automatic installation of security upgrades ii uncrustify 0.72.0+dfsg1-2 amd64 C, C++, ObjectiveC, C#, D, Java, Pawn and VALA source code beautifier ii unixodbc-common 2.3.9-5ubuntu0.1 all Common ODBC configuration files ii update-inetd 4.51 all inetd configuration file updater ii update-manager 1:22.04.22 all GNOME application that manages apt updates ii update-manager-core 1:22.04.22 all manage release upgrades ii update-notifier 3.192.54.8 amd64 Daemon which notifies about package updates ii update-notifier-common 3.192.54.8 all Files shared between update-notifier and other packages ii upower 0.99.17-1 amd64 abstraction for power management ii usb-creator-common 0.3.13 all create a startup disk using a CD or disc image (common files) ii usb-creator-gtk 0.3.13 all create a startup disk using a CD or disc image (for GNOME) ii usb-modeswitch 2.6.1-3ubuntu2 amd64 mode switching tool for controlling "flip flop" USB devices ii usb-modeswitch-data 20191128-4 all mode switching data for usb-modeswitch ii usrmerge 25ubuntu2 all Convert the system to the merged /usr directories scheme ii va-driver-all:amd64 2.14.0-1 amd64 Video Acceleration (VA) API -- driver metapackage ii vdpau-driver-all:amd64 1.4-3build2 amd64 Video Decode and Presentation API for Unix (driver metapackage) ii vtk9 9.1.0+really9.1.0+dfsg2-3build1 amd64 Binaries for VTK9 ii wamerican 2020.12.07-2 all American English dictionary words for /usr/share/dict ii wbritish 2020.12.07-2 all British English dictionary words for /usr/share/dict ii wget 1.21.2-2ubuntu1.1 amd64 retrieves files from the web ii whiptail 0.52.21-5ubuntu2 amd64 Displays user-friendly dialog boxes from shell scripts ii whoopsie-preferences 23 amd64 System preferences for error reporting ii wireless-regdb 2024.10.07-0ubuntu1~22.04.1 all wireless regulatory database ii wireless-tools 30~pre9-13.1ubuntu4 amd64 Tools for manipulating Linux Wireless Extensions ii x11-common 1:7.7+23ubuntu2 all X Window System (X.Org) infrastructure ii xbrlapi 6.4-4ubuntu3 amd64 Access software for a blind person using a braille display - xbrlapi ii xcvt 0.1.1-3 amd64 VESA CVT standard timing modelines generator ii xdg-dbus-proxy 0.1.3-1 amd64 filtering D-Bus proxy ii xdg-desktop-portal 1.14.4-1ubuntu2~22.04.2 amd64 desktop integration portal for Flatpak and Snap ii xdg-desktop-portal-gnome 42.1-0ubuntu2 amd64 GNOME portal backend for xdg-desktop-portal ii xdg-desktop-portal-gtk 1.14.0-1build1 amd64 GTK+/GNOME portal backend for xdg-desktop-portal ii xdg-user-dirs 0.17-2ubuntu4 amd64 tool to manage well known user directories ii xdg-user-dirs-gtk 0.10-3build2 amd64 tool to manage well known user directories (Gtk extension) ii xdg-utils 1.1.3-4.1ubuntu3~22.04.1 all desktop integration utilities from freedesktop.org ii xfonts-encodings 1:1.0.5-0ubuntu2 all Encodings for X.Org fonts ii xfonts-utils 1:7.7+6build2 amd64 X Window System font utility programs ii xinput 1.6.3-1build2 amd64 Runtime configuration and test of XInput devices ii xkb-data 2.33-1 all X Keyboard Extension (XKB) configuration data ii xml-core 0.18+nmu1 all XML infrastructure and XML catalog file support ii xorg 1:7.7+23ubuntu2 amd64 X.Org X Window System ii xorg-docs-core 1:1.7.1-1.2 all Core documentation for the X.org X Window System ii xorg-sgml-doctools 1:1.11-1.1 all Common tools for building X.Org SGML documentation ii xserver-xorg 1:7.7+23ubuntu2 amd64 X.Org X server ii xserver-xorg-core 2:21.1.4-2ubuntu1.7~22.04.15 amd64 Xorg X server - core server ii xserver-xorg-input-all 1:7.7+23ubuntu2 amd64 X.Org X server -- input driver metapackage ii xserver-xorg-input-libinput 1.2.1-1 amd64 X.Org X server -- libinput input driver ii xserver-xorg-input-wacom 1:1.0.0-3ubuntu1 amd64 X.Org X server -- Wacom input driver ii xserver-xorg-legacy 2:21.1.4-2ubuntu1.7~22.04.15 amd64 setuid root Xorg server wrapper ii xserver-xorg-video-all 1:7.7+23ubuntu2 amd64 X.Org X server -- output driver metapackage ii xserver-xorg-video-amdgpu 22.0.0-1ubuntu0.2 amd64 X.Org X server -- AMDGPU display driver ii xserver-xorg-video-ati 1:19.1.0-2ubuntu1 amd64 X.Org X server -- AMD/ATI display driver wrapper ii xserver-xorg-video-fbdev 1:0.5.0-2build1 amd64 X.Org X server -- fbdev display driver ii xserver-xorg-video-intel 2:2.99.917+git20210115-1 amd64 X.Org X server -- Intel i8xx, i9xx display driver ii xserver-xorg-video-nouveau 1:1.0.17-2build1 amd64 X.Org X server -- Nouveau display driver ii xserver-xorg-video-qxl 0.1.5+git20200331-3 amd64 X.Org X server -- QXL display driver ii xserver-xorg-video-radeon 1:19.1.0-2ubuntu1 amd64 X.Org X server -- AMD/ATI Radeon display driver ii xserver-xorg-video-vesa 1:2.5.0-1build4 amd64 X.Org X server -- VESA display driver ii xserver-xorg-video-vmware 1:13.3.0-3build1 amd64 X.Org X server -- VMware display driver ii xtl-dev 0.7.2-2 all basic tools (containers, algorithms) used for xtensor and xeus ii xwayland 2:22.1.1-1ubuntu0.19 amd64 X server for running X clients under Wayland ii xxd 2:8.2.3995-1ubuntu2.24 amd64 tool to make (or reverse) a hex dump ii yaru-theme-gnome-shell 22.04.5 all Yaru GNOME Shell desktop theme from the Ubuntu Community ii yaru-theme-gtk 22.04.5 all Yaru GTK theme from the Ubuntu Community ii zenity 3.42.1-0ubuntu1 amd64 Display graphical dialog boxes from shell scripts ii zenity-common 3.42.1-0ubuntu1 all Display graphical dialog boxes from shell scripts (common files) ii zlib1g:amd64 1:1.2.11.dfsg-2ubuntu9.2 amd64 compression library - runtime ii zlib1g-dev:amd64 1:1.2.11.dfsg-2ubuntu9.2 amd64 compression library - development ii zstd 1.4.8+dfsg-3build1 amd64 fast lossless compression algorithm -- CLI tool bash: 未预期的记号 "newline" 附近有语法错误 ubuntu@Ubuntu01:~/桌面$
最新发布
07-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值