编译安装qemu-devel @FreeBSD

缘起

使用cbsd创建riscv jail的时候提示:

you have no qemu-user, please install qemu-devle with BSD_USER and STATIC ops (emulators/qemu-devel)

使用pkg安装之后,创建的riscv jail启动报错:


Starting jail: fbriscv, parallel timeout=5
chroot: /bin/sh: Exec format error
 * Copying emulator to /bin
emulator error: /usr/sbin/chroot /usr/jails/basejail/base_riscv_riscv64_14.1 /bin/qemu-riscv64-static /bin/sh -c "echo ping": Assertion failed: (p_rcu_reader->depth != 0), function rcu_read_unlock, file /wrkdirs/usr/ports/emulators/qemu-user-static-devel/work/qemu-bsd-user-64ff0f053df/include/qemu/rcu.h, line 101.

于是准备重新编译安装qemu-devel

开工

首先安装prots系统:

git clone --depth 1 https://git.FreeBSD.org/ports.git /usr/ports

 

编译安装qemu-devel

进入/usr/ports/emulators/qemu-devel

执行make config 

make config

选中STATIC_LINK 回车

注意选了STATIC_LINK就不能选X11 support 和GTK3            GTK 3 GUI toolkit support 

经实验,选中STATIC_LINK无法编译成功,要去掉才行。

另外编译的时候需要用

make

而不能用make -j 8  ,带了-j参数会编译失败。

编译安装后提示:

FreeBSD host notes
==================- Needs to set net.link.tap.user_open sysctl in order to use /dev/tap*networking as non-root.  Don't forget to adjust device nodepermissions in /etc/devfs.rules.- slirp (usermode networking) is fixed now, you still have to manuallydo: echo nameserver 10.0.2.3 >/etc/resolv.conf but that is normal. Andyou have to wait a bit for dhclient to do its thing; traffic toaddress 10.0.2.2 is routed to 127.1 on the host.- The -smb option (smb-export local dir to guest using the default slirpnetworking) needs the samba port/package installed in addition toqemu. (SAMBA knob.)- If you want to use usb devices connected to the host in the guestyou can use usbredir over the network (see below); also unless you arerunning qemu as root you then need to fix permissions for /dev/ugen*device nodes: put a rule in /etc/devfs.rules, activate it in/etc/rc.conf and run /etc/rc.d/devfs restart.  Example devfs.rules:[ugen_ruleset=20]add path 'ugen*' mode 660 group operatorcorresponding rc.conf line:devfs_system_ruleset="ugen_ruleset"- If you want to test the new usb network redirection (USBREDIR option)see this thread by Hans de Goede <hdegoede <at> redhat.com>:http://thread.gmane.org/gmane.comp.emulators.qemu/110176/focus=110183Quote:Example usage:1) Start usbredirserver for a usb device:sudo usbredirserver 045e:07722) Start qemu with usb2 support + a chardev talking to usbredirserver +a usb-redir device using this chardev:qemu -usb \-readconfig docs/ich9-ehci-uhci.cfg \-chardev socket,id=usbredirchardev,host=localhost,port=4000 \-device usb-redir,chardev=usbredirchardev,id=usbredirdev ...[you would replace docs/ich9-ehci-uhci.cfg with e.g./usr/local/share/doc/qemu/docs/ich9-ehci-uhci.cfg, but turns outehci was broken for me here with FreeBSD guests and the previousqemu version at least, I got:FETCHENTRY: entry at 22C5484 is of type 2 which is not supported yet
processing error - resetting ehci HCAssertion failed: (0), function ehci_advance_state, file /data/ports/emulators/qemu-devel/work/qemu-0.15.0/hw/usb-ehci.c, line 2045.The new qemu version works better tho.]- Still usb: since the hub is no longer attached to the uchi controller andthe wakeup mechanism, resume interrupt is not implemented yet linux guestswill suspend the bus, i.e. they wont see devices usb_add'ed after its(linux') uhci module got loaded.  Workaround: either add devices beforelinux loads the module or rmmod and modprobe it afterwards.  [Not sureif this still applies to the new libusb host code used on recent10-current.]- If you get repeated `atapi_poll called!' console messages with FreeBSDguests or other weird cdrom problems then thats probably because the guesthas atapicam loaded, which for reasons still to be determined has problemswith qemu's now by default enabled cdrom dma.  You can build the port withCDROM_DMA disabled to disable it.  [Looks like this is fixed in recentFreeBSD guest versions.]- If you build qemu wihout SDL and then get crashes running it try passing it-nographic.- qemu's network boot roms (-boot n) have a bug when bootfiles sizes are amultiple of blksize, if this affects you (like with FreeBSD's /boot/pxeboot)you can do likecp /boot/pxeboot pxeboot-qemu && chmod +w pxeboot-qemu && echo >>pxeboot-qemuand then use pxeboot-qemu. Actually you need recent btx code becauseof the real mode boot problem, so use at least pxeboot from there.- If you use slirp (usernet, the default) and want to mount nfs into theguest and you are not running qemu as root, then mountd(8) on theexporting box needs to be run with -n in order to accept requests fromports >= 1024.- (not FreeBSD-specific:) There have been reports of qcow2 corruption with (atleast) win2k guests on recent kvm (which uses similar qcow2 code than qemunow, see this thread:http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg00713.html -the consensus on that thread seems to be that qcow(2) code has always beenexperimental and you should use raw images if you want reliability; raw isalso usually faster.)  You should be able to migrate existing images to rawusing qemu-img(1)'s convert function; raw doesn't support advanced featureslike snapshots tho.  [a few important qcow2 bugfixed have been committed inthe meantime so this _might_ be less of an issue now; and meanwhile therealso is the new qed format - I don't know how stable that one is.]- (also not FreeBSD-specific:)  It is recommended to pass raw images using thenew -drive syntax, specifying format=raw explicitly in order to avoidmalicious guests being able to exploit the format autodetection thatsotherwise getting used.  (Not that you should run malicious guests anyway,but this eleminates at least a known attack vector.)- qemu now has improved physical cdrom support, but still there is atleast one known problem: you need to have the guest eject the disc if youwant to change it/take it out, or otherwise the guest may continue usingstate (like size) of the old disc.  (You can also do like `change ide1-cd0/dev/acd0' in the monitor after taking out the disc if a guest cannot ejectit itself.)- The default configuration location (qemu-ifup script etc.) has been changedfrom /etc to PREFIX/etc (usually /usr/local/etc).  Move your filesaccordingly.- The pcap code (-net nic... -net pcap,ifname=...) should work properly now,with only one exception:  Advanced features like TSO used on the hostinterface can cause oversize packets which now do get truncated to avoidconfusing/panicing guests but of course still will cause retransmissions.So if you see slow throughput and `pcap_send: packet size > ..., truncating'messages on qemu's tty try disabling TSO etc on the host interface at leastwhile using pcap.- kqemu is no longer supported in qemu upstream after the 0.11 branchwas created, which means also not in this version.  (Linux has movedon to kvm now for qemu(-like) virtualization needs, so if you want qemuto go faster and don't want to switch to virtualbox or stick to the olderemulators/qemu port which is at 0.11.1 atm and as such still supportskqemu you should help getting the FreeBSD kvm port updated andcompleted:http://wiki.freebsd.org/FabioChecconi/PortingLinuxKVMToFreeBSD)===> SECURITY REPORT: This port has installed the following files which may act as networkservers and may therefore pose a remote security risk to the system.
/usr/local/bin/qemu-img
/usr/local/bin/qemu-system-nios2
/usr/local/bin/qemu-system-riscv64
/usr/local/bin/qemu-system-mips64
/usr/local/bin/qemu-system-mips64el
/usr/local/bin/qemu-system-loongarch64
/usr/local/bin/qemu-system-microblaze
/usr/local/bin/qemu-system-sparc
/usr/local/bin/qemu-system-riscv32
/usr/local/bin/qemu-nbd
/usr/local/bin/qemu-system-ppc64
/usr/local/bin/qemu-system-avr
/usr/local/bin/qemu-system-sh4
/usr/local/bin/qemu-system-or1k
/usr/local/bin/qemu-system-cris
/usr/local/bin/qemu-x86_64
/usr/local/bin/qemu-system-mipsel
/usr/local/bin/qemu-system-alpha
/usr/local/bin/qemu-edid
/usr/local/bin/qemu-system-sparc64
/usr/local/bin/qemu-arm
/usr/local/bin/qemu-storage-daemon
/usr/local/bin/qemu-system-ppc
/usr/local/bin/qemu-system-microblazeel
/usr/local/bin/qemu-system-xtensa
/usr/local/bin/qemu-system-aarch64
/usr/local/bin/qemu-system-xtensaeb
/usr/local/bin/qemu-io
/usr/local/bin/qemu-i386
/usr/local/bin/qemu-system-sh4eb
/usr/local/bin/qemu-system-arm
/usr/local/bin/qemu-system-m68k
/usr/local/bin/qemu-system-i386
/usr/local/bin/qemu-system-x86_64
/usr/local/bin/qemu-system-s390x
/usr/local/bin/qemu-system-mips
/usr/local/bin/qemu-system-rx
/usr/local/bin/qemu-system-hppa
/usr/local/bin/qemu-system-tricoreIf there are vulnerabilities in these programs there may be a securityrisk to the system. FreeBSD makes no guarantee about the security ofports included in the Ports Collection. Please type 'make deinstall'to deinstall the port if this is a concern.For more information, and contact details about the securitystatus of this software, see the following webpage: 
https://www.qemu.org/

编译安装的时候有很多波折,见后面调试部分

pkg 安装qemu

本来已经pkg 安装qemu-devel,再把qemu装上,发现还是新装了几个软件

pkg install qemu

装好后提示:

Message from qemu-8.2.2_1:

--
FreeBSD host notes
==================

- Needs to set net.link.tap.user_open sysctl in order to use /dev/tap*
  networking as non-root.  Don't forget to adjust device node permissions in
  /etc/devfs.rules.

- Expect timer problems when guest kernel HZ is > hosts.  The linux 2.6
  kernel uses 1000 by default btw.  (changed to 250 later, and recent linux
  kernels now no longer have a fixed HZ, aka `tickless kernel'...)
  Enabling /dev/rtc doesn't seem to help either (not included since it needs
  a patch to emulators/rtc.)

- The -smb option (smb-export local dir to guest using the default
  slirp networking) needs the samba port/package installed
  in addition to qemu. (SAMBA knob.)

- If you want to use usb devices connected to the host in the guest
  yot can use usbredir over the network (see below); also unless you are
  running qemu as root you then need to fix permissions for /dev/ugen*
  device nodes: if you are on 5.x or later (devfs) put a rule in
  /etc/devfs.rules, activate it in /etc/rc.conf and run /etc/rc.d/devfs
  restart.  Example devfs.rules:

    [ugen_ruleset=20]
    add path 'ugen*' mode 660 group operator

  corresponding rc.conf line:

    devfs_system_ruleset="ugen_ruleset"

- Still usb: since the hub is no longer attached to the uchi controller and
  the wakeup mechanism, resume interrupt is not implemented yet linux guests
  will suspend the bus, i.e. they wont see devices usb_add'ed after its
  (linux') uhci module got loaded.  Workaround: either add devices before
  linux loads the module or rmmod and modprobe it afterwards.  [Not sure
  if this still applies to the new libusb host code used on recent
  10-current.]

- If you get repeated `atapi_poll called!' console messages with FreeBSD
  guests or other weird cdrom problems then thats probably because the guest
  has atapicam loaded, which for reasons still to be determined has problems
  with qemu's now by default enabled cdrom dma. You can build the port with
  CDROM_DMA disabled to disable it.  [Looks like this is fixed in recent
  FreeBSD guest versions.]

- If you build qemu wihout SDL and then get crashes running it try passing it
  -nographic.  This should probably be default in that case...

- qemu's network boot roms (-boot n) have a bug when bootfiles sizes are a
  multiple of blksize, if this affects you (like with FreeBSD's /boot/pxeboot)
  you can do like

    cp /boot/pxeboot pxeboot-qemu && chmod +w pxeboot-qemu && echo >>pxeboot-qemu

  and then use pxeboot-qemu.  Actually you need recent btx code
  (from after 7.0 was released) because of the real mode boot
  problem, so use at least pxeboot from there.  And I just did that
  for the pxeboot extracted out of

    ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/200805/7.0-STABLE-200805-i386-bootonly.iso

  and placed it here:

    http://people.freebsd.org/~nox/qemu/pxeboot-qemu

- If you use slirp (usernet, the default) and want to mount nfs into the guest
  and you are not running qemu as root, then mountd(8) on the exporting box
  needs to be run with -n in order to accept requests from ports >= 1024.
root@fbhost:/usr/ports/emulators/qemu-devel # 

后来又重新安装了qemu-devel

pkg install qemu-devel

当时之所以编译安装,就是为了STATIC_LINK这个参数。但是编译安装的时候用了这个参数也编译不过去,所以不如直接pkg按钻个方便了。

 

调试

报错pkg-static: open(/usr/ports/textproc/py-sphinx/work-py311/.metadir.py311-sphinx): No such file or directory

--- security-check ---
--- fake-pkg.py311-sphinx ---
===>   Registering installation for py311-sphinx-5.3.0_1,1 as automatic
pkg-static: open(/usr/ports/textproc/py-sphinx/work-py311/.metadir.py311-sphinx): No such file or directory
*** [fake-pkg.py311-sphinx] Error code 1

make[2]: stopped in /usr/ports/textproc/py-sphinx

尝试 pkg install textproc/py-sphinx

不行。尝试pkg install textproc/py-sphinx_rtd_theme

还是不行。尝试pkg install python311 ,还是不行

删除work-py311目录,不行

期间发现安装的python311无法执行,原来是老终端里没有更新path,重新登录即可执行python3.11

执行python3.11 -m ensurepip ,这样就安装好了Successfully installed pip-24.0 setuptools-65.5.0 

还是不行。在python里面安装sphinx_rtd_theme

python3.11 -m pip install sphinx_rtd_theme

还是不行,把Makefile修改一下,去掉sphinx的依赖

# BUILD_DEPENDS=        sphinx-build:textproc/py-sphinx \${PYTHON_PKGNAMEPREFIX}sphinx_rtd_theme>0:textproc/py-sphinx_rtd_theme@${PY_FLAV
OR} \

 出现新的报错

如何提高pip安装软件的速度

python3.11 -m pip config set global.index-url  https://mirror.baidu.com/pypi/simple

报错pkg-static: open(/usr/ports/devel/bison/work/.metadir.bison): No such file or directory

===>   Registering installation for bison-3.8.2_2,1 as automatic
pkg-static: open(/usr/ports/devel/bison/work/.metadir.bison): No such file or directory
*** [fake-pkg.bison] Error code 1

pkg install bison-3.8.2_1,1
搞定

报错没有cmake

pkg install gmake 搞定

报错没有ninja

发现Makefile还有几个需求,一起装了

pkg install ninja perl5 pkgconfig

结果不行,还是一个一个装吧:pkg install ninja

安装pkg install print/texinfo

报错../meson.build:2420:15: ERROR: C prefer_static library 'inotify' not found

Header "sys/inotify.h" has symbol "inotify_init" : YES 
Header "sys/inotify.h" has symbol "inotify_init1" : YES 

../meson.build:2420:15: ERROR: C prefer_static library 'inotify' not found

A full log can be found at /usr/ports/emulators/qemu-devel/work/qemu-ff202817dc2b0b3b42992fa7f1c
e503f081068fe/build/meson-logs/meson-log.txt
ERROR: meson setup failed
===>  Script "configure" failed unexpectedly.
Please report the problem to bofh@FreeBSD.org [maintainer] and attach the
"/usr/ports/emulators/qemu-devel/work/qemu-ff202817dc2b0b3b42992fa7f1ce503f081068fe/config.log"
including the output of the failure of your make command. Also, it might be
a good idea to provide an overview of all packages installed on your system
怀疑是把Makefile里面的sphinx注释掉的原因。把注释去掉,还是报错

BUILD_DEPENDS=  sphinx-build:textproc/py-sphinx

到目录/usr/ports/textproc/py-sphinx_rtd_theme

然后make install

再回到目录/usr/ports/emulators/qemu-devel 

make install ,依旧。

针对这个报错,重新编译meson

cd /usr/ports/devel/meson && make install

依旧。

但是把STATIC_LINK选项去掉,能编译下去了。

最后编译完了之后报错...

编译结束之后报错几个文件找不到

把make -j 8 改成make ,就又能继续下去了。

但是最终make install的时候报错:

===>   Registering installation for qemu-devel-8.3.0.20240229
pkg-static: Unable to access file /usr/ports/emulators/qemu-devel/work/stage/usr/local/include/fdt.h:No such file or directory
pkg-static: Unable to access file /usr/ports/emulators/qemu-devel/work/stage/usr/local/include/libfdt.h:No such file or directory
pkg-static: Unable to access file /usr/ports/emulators/qemu-devel/work/stage/usr/local/include/libfdt_env.h:No such file or directory
pkg-static: Unable to access file /usr/ports/emulators/qemu-devel/work/stage/usr/local/lib/libfdt.a:No such file or directory
pkg-static: Unable to access file /usr/ports/emulators/qemu-devel/work/stage/usr/local/libdata/pkgconfig/libfdt.pc:No such file or directory
*** Error code 1
可能是前面pkg install qemu导致的,执行pkg install qemu-devel

然后再来make install,提示需要先uninstall reinstall ,结果还是报错文件找不到。

最后是重新删除build目录,创建build目录,重新make config ,make install,终于编译成功了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/28012.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

华为数通题库HCIP-821——最新最全(带答案解析)

单选1、下面是一台路由器的输出信息&#xff0c;关于这段信息描述正确的是 A目的网段1.1.1.0/24所携带的团体属性值是no—export表明该路由条目不能通告给任何BGP邻居 B目的网段5.1.1.0/24所携带的团体属性值是no—advertise表明该路由条目不能被通告给任何其他的BGP对等体 C…

大数据概论总结

三次信息化浪潮 : 信息技术的支撑 : 存储设备容量不断增加 CPU的处理能力不断提高 网络带宽不断增加 数据产生方式的变革促成大数据时代的来临 运营式系统阶段用户原创内容感知式系统阶段 大数据发展历程 : 分为三个阶段 : 大数据的概念 : 1 . 数据量大 : 根据IDC作出…

Unity:Text-TextMeshPro 不显示中文

共计四步&#xff1a; 一、去C盘复制一份字体&#xff1a; C:\Windows\Fonts二、粘贴到你的项目里&#xff08;任意文件位置&#xff09;&#xff0c;得到“MSYH”&#xff1a; 三、右键字体文件&#xff0c;依次点击create–>TextMeshPro–>FontAsset&#xff1a; …

Mac平台上公认的最好的下载工具Folx Pro 5 for Mac激活码

Folx是什么 Folx Pro 5 for Mac是Mac平台上公认的最好的下载工具&#xff0c;功能可以与迅雷相媲美。 Folx是一款老牌下载神器&#xff0c;可通过URL链接和种子文件下载文件&#xff0c;同时提供了便捷的下载管理和灵活的应用设置&#xff0c;Folx可以对下载的资源进行分类&a…

勒索病毒搜索引擎

360勒索病毒搜索引擎 https://lesuobingdu.360.cn/ 腾讯勒索病毒搜索引擎 https://guanjia.qq.com/pr/ls/ VenusEye勒索病毒搜索引擎 https://lesuo.venuseye.com.cn/ 奇安信勒索病毒搜索引擎 https://lesuobingdu.qianxin.com/index/getFile 深信服勒索病毒搜索引擎…

韩顺平0基础学java——第22

p460-483 常用类 包装类Wrapper 针对8种几种数据类型相应的引用类型——包装类 包装类和基本数据类型的转换 jdk5之前的手动装箱和拆箱&#xff1a; jdk5之后的自动装箱和拆箱&#xff1a; 三元运算符是一个整体&#xff1a; 这个三元运算符里&#xff0c;精度最高的是doubl…

非线性规划解决工资分配问题

来源&#xff1a;河北工业职业技术大学 安彤彤 彭金杉 张家硕 题目 薪资发放问题 一般公司给职员发放薪金&#xff0c;通常按每月等额发放。某公司即将改进薪金发放方案&#xff0c;允许任职5年以上的职员向公司财务部门申请工资每月可变额度发放&#xff0c;每月工资发放额…

嵌入式系统中常用的参数存储方法

一、有哪些参数需要管理? 在智能硬件产品中,一般有三类数据需要存储并管理: 1. 系统设置数据 系统设置数据是指产品自身正常工作所依赖的一些参数。 这类数据的特点:只能在生产过程中修改,出厂后用户无权限修改。 比如:产品 SN、产品密钥/token/license、传感器校准值…

应急响应处置思路与流程

HVV中常见应急问题&#xff1a; 不确定攻击成功 服务器进行排查 windows服务器 账号排查 隐藏用户排查 net userwmic查看用户管理查看注册列表查看 账户登录日志排查 4624登录成功4625登录失败4720账户创建4724尝试重置密码4738账户已更改 logoff踢出用户 网络连接排…

如何用AI提高产品经理的工作效率

最近我跟几个产品经理聊天&#xff0c;发现有些人居然还没有使用过ChatGPT、MidJourney、NotionAI 等AI工具。 产品经理有个重要的素质是好奇心&#xff0c;好奇心能够帮助产品经理发现新机会、了解用户需求、学习新知识和探索竞争对手&#xff0c;从而更好地完成产品开发和管…

Java基础语法Ⅰ【注释、关键字、字面量、变量】

Java基础语法① 注释关键字与标识符数据类型字面量和常量变量转义字符 注释 注释是在写代码时&#xff0c;对代码作出的一些解释说明&#xff0c;比如某一个函数的作用&#xff08;功能&#xff09;、函数接收的参数以及函数返回什么东西等等。 这些解释说明没有任何功能&…

轻松拿捏C语言——【关机代码】

&#x1f970;欢迎关注 轻松拿捏C语言系列&#xff0c;来和 小哇 一起进步&#xff01;✊ &#x1f389;创作不易&#xff0c;请多多支持&#x1f389; &#x1f308;感谢大家的阅读、点赞、收藏和关注&#x1f495; &#x1f339;如有问题&#xff0c;欢迎指正 我们可以通过写…

Java面试题汇总(持续更新.....)

Java面试题 1. JVM & JDK & JRE Java虚拟机&#xff08;JVM&#xff09;是运行Java字节码的虚拟机&#xff0c;JVM有针对不同系统的特定实现&#xff0c;目的是使用相同的字节码&#xff0c;他们都会给出相同的结果。字节码和不同系统的JVM实现是Java语言“一次编译、…

【Java】类与类的关系及其总结

类和类的关系 代码 总结&#xff1a; 【1】面向对象的思维&#xff1a;找参与者&#xff0c;找女孩类&#xff0c;找男孩类 【2】体会了什么叫方法的性擦&#xff0c;什么叫方法的实参&#xff1a; 具体传入的内容 实参&#xff1a; 【3】类和类可以产生关系&#xff1a; …

GenICam标准(六)

系列文章目录 GenICam标准&#xff08;一&#xff09; GenICam标准&#xff08;二&#xff09; GenICam标准&#xff08;三&#xff09; GenICam标准&#xff08;四&#xff09; GenICam标准&#xff08;五&#xff09; GenICam标准&#xff08;六&#xff09; 文章目录 系列文…

【会议征稿,IEEE出版】第六届物联网、自动化和人工智能国际学术会议(IoTAAI 2024,7月26-28)

第六届物联网、自动化和人工智能国际会议&#xff08;IoTAAI 2024&#xff09;将于2024年07月26-28日在中国广州召开。 会议旨在拓展国际科技学术交流渠道&#xff0c;搭建学术资源共享平台&#xff0c;促进全球范围内的科技创新&#xff0c;提升中外学术合作。会议还鼓励不同领…

剃头师傅不担心AI大模型 到底谁该担心?

到底学什么&#xff0c;不会被AI替代&#xff1f; 我家附近有一家美容店&#xff0c;已经开了20多年&#xff0c;店里的一位伙计硬是靠着自己的坚持从学徒熬成了门店的合伙人&#xff0c;所以现在去理发时&#xff0c;我都叫他“周董”。 这天&#xff0c;我问他&#xff0c;…

力扣hot100:75. 颜色分类(双指针)

75.颜色分类 本题是经典的「荷兰国旗问题」&#xff0c;由计算机科学家 Edsger W. Dijkstra 首先提出。 75. 颜色分类 1、遍历两遍 遍历两遍&#xff0c;第一遍放置0的位置&#xff0c;第二遍放置1的位置&#xff0c;我们只需要维护一个当前放置位置即可。 class Solution…

pytorch学习笔记6

想要找一些官方的小工具数据集&#xff0c;可以进入pytorch官网&#xff0c;DOCS-》pytorch下拉至libraries&#xff0c;点击torchversion&#xff0c;调整版本至0.9.0就可以找到相应的一些数据集&#xff0c;训练集 ctrlp可以看一个函数中需要设置哪些参数 下载数据集可以参考…

【设计模式深度剖析】【6】【行为型】【中介者模式】

&#x1f448;️上一篇:迭代器模式 | 下一篇:观察者模式&#x1f449;️ 设计模式-专栏&#x1f448;️ 文章目录 中介者模式定义英文原文直译如何理解&#xff1f; 中介者模式的角色1. 中介者&#xff08;Mediator&#xff09;2. 具体中介者&#xff08;ConcreteMediato…