编译安装qemu-devel @FreeBSD

news2024/11/26 2:41:19

缘起

使用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 node
  permissions in /etc/devfs.rules.

- slirp (usermode networking) is fixed now, you still have to manually
  do: echo nameserver 10.0.2.3 >/etc/resolv.conf but that is normal. And
  you have to wait a bit for dhclient to do its thing; traffic to
  address 10.0.2.2 is routed to 127.1 on the host.

- 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
  you 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: 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"

- 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=110183

  Quote:

  Example usage:

  1) Start usbredirserver for a usb device:
  sudo usbredirserver 045e:0772
  2) 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 out
  ehci was broken for me here with FreeBSD guests and the previous
  qemu version at least, I got:

	FETCHENTRY: entry at 22C5484 is of type 2 which is not supported yet
processing error - resetting ehci HC
	Assertion 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 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.

- 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 because
  of 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 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.

- (not FreeBSD-specific:) There have been reports of qcow2 corruption with (at
  least) win2k guests on recent kvm (which uses similar qcow2 code than qemu
  now, 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 been
  experimental and you should use raw images if you want reliability; raw is
  also usually faster.)  You should be able to migrate existing images to raw
  using qemu-img(1)'s convert function; raw doesn't support advanced features
  like snapshots tho.  [a few important qcow2 bugfixed have been committed in
  the meantime so this _might_ be less of an issue now; and meanwhile there
  also 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 the
  new -drive syntax, specifying format=raw explicitly in order to avoid
  malicious guests being able to exploit the format autodetection thats
  otherwise 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 at
  least one known problem: you need to have the guest eject the disc if you
  want to change it/take it out, or otherwise the guest may continue using
  state (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 eject
  it itself.)

- The default configuration location (qemu-ifup script etc.) has been changed
  from /etc to PREFIX/etc (usually /usr/local/etc).  Move your files
  accordingly.

- The pcap code (-net nic... -net pcap,ifname=...) should work properly now,
  with only one exception:  Advanced features like TSO used on the host
  interface can cause oversize packets which now do get truncated to avoid
  confusing/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 least
  while using pcap.

- kqemu is no longer supported in qemu upstream after the 0.11 branch
  was created, which means also not in this version.  (Linux has moved
  on to kvm now for qemu(-like) virtualization needs, so if you want qemu
  to go faster and don't want to switch to virtualbox or stick to the older
  emulators/qemu port which is at 0.11.1 atm and as such still supports
  kqemu you should help getting the FreeBSD kvm port updated and
  completed:

	http://wiki.freebsd.org/FabioChecconi/PortingLinuxKVMToFreeBSD

  )

===> SECURITY REPORT: 
      This port has installed the following files which may act as network
      servers 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-tricore

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports 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 security
      status 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.coloradmin.cn/o/1827407.html

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

相关文章

【猫狗分类】Pytorch VGG16 实现猫狗分类2-模型构建

背景 数据处理做好了&#xff0c;现在搭建网络 声明&#xff1a;整个数据和代码来自于b站&#xff0c;链接&#xff1a;使用pytorch框架手把手教你利用VGG16网络编写猫狗分类程序_哔哩哔哩_bilibili 我做了复现&#xff0c;并且记录了自己在做这个项目分类时候&#xff0c;一…

【回文 马拉车】214. 最短回文串

本文涉及知识点 回文 马拉车 LeetCode214. 最短回文串 给定一个字符串 s&#xff0c;你可以通过在字符串前面添加字符将其转换为回文串。找到并返回可以用这种方式转换的最短回文串。 示例 1&#xff1a; 输入&#xff1a;s “aacecaaa” 输出&#xff1a;“aaacecaaa” 示…

string类的使用手册

1.构造函数 补充&#xff1a;npos&#xff1a;size_t类型数据的最大值 default (1) string(); 构造空的string类对象 copy (2) string (const string& str); 拷贝构造函数&#xff08;深拷贝&#xff09; substring (3) string (const string& str, size_t pos, size_…

python 实现各种数据分析方法

1、相关性分析 1.1、https://zhuanlan.zhihu.com/p/669355778https://zhuanlan.zhihu.com/p/669355778

【AI学习】Together AI的新研究:Together MoA(Mixture of Agents)

第一次听说Mixture of Agents&#xff0c;原来Agent也能混合&#xff0c;有意思&#xff01; 介绍 Together AI的最新研究“Together MoA”&#xff08;Mixture of Agents&#xff0c;代理混合&#xff09;是一种创新的方法&#xff0c;旨在通过结合多个开源大型语言模型&…

Postman使用教程(Postman详细图文教程)

本文讲解的是postman工具安装、postman安装教程、postman工具下载、postman使用教程。Postman使得得开发人员和测试人员能够更高效地与Web服务进行交互和调试。 Postman不仅支持常见的HTTP方法&#xff0c;如GET、POST、PUT、DELETE等&#xff0c;还提供了丰富的请求编辑功能&…

Linux---防火墙

文章目录 目录 文章目录 前言 一.静态防火墙&#xff1a;iptables iptables五链 iptables 四表 iptables控制类型 iptables命令配置 前言 这儿主要介绍Linux系统本身提供的软件防火墙的功能&#xff0c;即数据包过滤机制。 数据包过滤&#xff0c;也就是分析进入主机的网络数…

Ubuntu20.04配置ORBSLAM2并在kitti数据集序列进行实验

一、ORB-SLAM2 安装和编译 1.ORB-SLAM2下载 用以下命令在终端上下载 git clone https://github.com/raulmur/ORB_SLAM2 2.安装Pangolin 在下载了ZIP压缩包后解压缩放在ubantu的/home下&#xff08;此处只要是英文路径都可以&#xff09;&#xff0c;但别急着安装Pangolin我…

STM32项目分享:智慧农业(机智云)系统

目录 一、前言 二、项目简介 1.功能详解 2.主要器件 三、原理图设计 四、PCB硬件设计 1.PCB图 2.PCB板打样焊接图 五、程序设计 六、实验效果 七、资料内容 项目分享 一、前言 项目成品图片&#xff1a; 哔哩哔哩视频链接&#xff1a; https://www.bilibili.c…

PCIe总线-RK3588 PCIe子系统简介(八)

1.PCIe子系统 RK3588 PCIe子系统如下图所示。总共拥有5个PCIe控制器。PCIe30X4(4L)支持RC和EP模式&#xff0c;其他4个仅支持RC模式。ITS port 1连接PCIe30X4(4L)和PCIe30X2(2L)控制器&#xff0c;PCIe30X4(4L)和PCIe30X2(2L)控制器使用PCIe3.0 PIPE PHY。ITS port 0连接PCIe3…

mysql:简单理解mysql mvcc的可重复读

# 原理 假设有这样的sql begin select&#xff08;或update、insert、delete&#xff09; ... commit当执行【begin】的时候&#xff0c;标记有一个新事务要开始&#xff0c;但是事务还没有真正开始&#xff0c;事务id还没有产生当执行事务里面的第一个sql语句时&#xff08;…

VCG显示——汉字,数字,图像

详细的介绍资料&#xff1a; 【从零开始走进FPGA】 玩转VGA http://www.cnblogs.com/spartan/archive/2011/08/16/2140546.html 【FPGA实验】基于DE2-115平台的VGA显示_vga接口实验 de2-115-CSDN博客 【FPGA】VGA显示文字、彩条、图片——基于DE2-115-CSDN博客 一.VCG原理 1.1…

区块链中的gas与转账收款相关概念

区块链是一个经济系统 计算与存储系统都是稀缺的&#xff0c;区块链的工作需要消耗资源共识、trustless需要矿工的工作&#xff0c;而矿工需要激励Transaction的执行有成本&#xff08;gas&#xff09;,gas费成为矿工的奖励ether是这个经济生态系统的通行货币 关心的问题 合…

Stable Diffusion vs DALL·E3

大模型技术论文不断&#xff0c;每个月总会新增上千篇。本专栏精选论文重点解读&#xff0c;主题还是围绕着行业实践和工程量产。若在某个环节出现卡点&#xff0c;可以回到大模型必备腔调或者LLM背后的基础模型新阅读。而最新科技&#xff08;Mamba,xLSTM,KAN&#xff09;则提…

父亲节:我要做爸爸的健康监督员

父亲节将至&#xff0c;总想着能为爸爸做些什么&#xff0c;来表达我们的感激与关爱。在这个特殊的日子里&#xff0c;成为爸爸的健康监督员&#xff0c;用华为 Watch 4 的智慧健康功能&#xff0c;任何时刻都可以关注爸爸的健康状况&#xff0c;放心又安心了。 用一键微体检…

C++ 50 之 继承中的对象模型

继承中的对象模型 在C编译器的内部可以理解为结构体&#xff0c;子类是由父类成员叠加子类新成员而成&#xff1a; #include <iostream> #include <string> using namespace std;class Base03{ public:int m_a; protected:int m_b; private:int m_c; // 哪怕是…

DNS域名解析----分离解析、多域名解析、父域与子域

1 理论部分 1.1 分离解析 DNS的分离解析&#xff0c;是指根据不同的客户端提供不同的域名解析记录。来自不同地址的客户机请求解析同一域名时&#xff0c;为其提供不同的解析结果。也就是内外网客户请求访问相同的域名时&#xff0c;能解析出不同的IP地址&#xff0c;实现负载…

汇编:Linux汇编基本框架与系统调用

在Linux操作系统下进行汇编编程时&#xff0c;基本的汇编程序框架通常包括以下几个部分&#xff1a; ①全局段声明&#xff08;section declarations&#xff09;&#xff1a;定义数据段、代码段等。 ②入口点&#xff08;entry point&#xff09;&#xff1a;程序的执行起点…

Python 显示笔记本电脑的电池状态和百分比

方法一&#xff1a; import psutil import psutil battery psutil.sensors_battery() if battery is None:print("No battery is found.")exit() print (battery) percentagebattery.percent print(f"Battery Percentage: {percentage}%")Battery的信息…

一个在C#中集成Python的例子

一个在C#中集成Python的例子。在C#中可以执行Python脚本&#xff0c;在Python中也可以调用C#宿主中的功能&#xff08;clr.AddReference(Business)&#xff09;。 文件说明 Debug为执行目录 Mgr.exe为执行文件 Py\init.py为python初始化脚本 Py\Lib.zip为python需要的模块&…