DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: szliyu112358
今日帖子: 57
在线用户: 19
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 pcplayer (pcplayer) ★☆☆☆☆ -
普通会员
2022/7/5 2:28:17
标题:
在 WINDOWS 的 WSL 里面的 LINUX 上运行 GUI 程序 浏览:2006
加入我的收藏
楼主: 官方链接:https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps

为了让这个跑起来,我把电脑升级到 WIN 11 了。也许 WIN 10 也是可以的?

安装成功一个程序之后,运行,总是提示连不上 server,也就是 GUI 出不来。

最后才查到如何把 wsl 1 升级为 wsl 2;微软官方的 github 页面上有说明。

然后真的可以把一个 Linux GUI 程序跑起来,GUI 窗口也出来了。而且这个 GUI 窗口直接是在 WINDOWS 的桌面上随便拖位置,而不是像虚拟机是在虚拟机的窗口里面。

那么,接下来,就可以试试用 Delphi 开发的 Linux GUI 程序是否也可以这样运行了。

之前测试过,用 Delphi 编译一个没界面的 Linux 程序,在 Windows WSL 的 Ubuntu 里面是可以运行起来的。
----------------------------------------------
-
作者:
男 pcplayer (pcplayer) ★☆☆☆☆ -
普通会员
2022/7/5 2:29:43
1楼: 顺便推荐一个古老的,当年我在 Apple II 上面玩过的游戏:

https://www.crazygames.com/game/lode-runner
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/5 6:06:53
2楼: hi @pcplayer

my post here on forum already show this!

NO NEEDS Windows 11

MSWindows 10 + [WSL + XvcSrv] or Win10 + [Docker + Ubuntu + XvcSrv]

How to test your Delphi projects in Linux using WSL/2 (Windows SubSystem Linux) in Win10 no more VMs 
http://bbs.2ccc.com/topic.asp?topicid=631045


How to run app FMX (GUI) in a Ubuntu on Docker environment? by Emailx45
http://bbs.2ccc.com/topic.asp?topicid=631439

and in WeDelphi.com I have this same post complete with screenshots!

and to update WSL 1 to 2 it's necessary in PowerShell type this command, after install 2nd version

wsl --install

wsl --set-version

https://docs.microsoft.com/en-us/windows/wsl/install
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2022/7/5 9:37:03
3楼: 从amd的说明来看 先支持win10 64

微软之前 有个第三方可以跑 gui我试过 忘记叫啥了
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/5 10:06:41
4楼: XServer for GUI apps in Linux:

X410  - comercial
https://token2shell.com/x410/

Open-Source/Free
Xmin
http://www.straightrunning.com/XmingNotes/

VcXsrv
https://sourceforge.net/projects/vcxsrv/

Putty for Windows --> have a X11 in options!
https://www.putty.org/
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/5 10:09:58
5楼: Ubuntu WSL Integration by code:

https://github.com/canonical/ubuntu-wsl-integration/blob/ac8ad6b20e7263ff5e706e539a3e19e2498135ae/debian/wsl-integration.sh#L43
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 ddrfan (若苗瞬) ▲▲▲▲▲ -
普通会员
2022/7/7 1:55:53
6楼: 微软说:
You will need to be on Windows 11 Build 22000 or later to access this feature.



我在Win10和Win11下分别试了试。

Win11直接安装WSL再分别升级后,全部“官方”操作,确实可以展示GUI程序。
不仅gedit,自己的程序也可以显示(新装的没中文)。

Win10同样操作,但不能运行GUI程序,显示:
Unable to init server: Could not connect: Connection refused
(gedit:7343): Gtk-WARNING **: 01:42:55.140: cannot open display:

此帖子包含附件:
PNG 图像
大小:229.7K
----------------------------------------------
Bye bye DDRFAN...
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/7 5:04:43
7楼: In MS Windows 10 you can run GUI apps (FMX) without no problem!!!

just install a "X"Server on MSWindows to receive the "redirect from XServer lib on Linux"... and define the Linux configuration for this!

apt-get install X11-apps

and add this line in your ".bashrc" file

- sudo vi .bashrc

add this command-line in "last line in your .bashrc file"

now, your .bashrc is open and ready for work... then type this command-line and save the file :
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
----------

any XServer will be used! This is done in MSWin11 by default if WSL installed!

in MSWindows 10, install the XServer like "XvcSrv" and add a param "-ac" when run it!



Then, it's just another way to have the same resulted!

just read my post at:
http://bbs.2ccc.com/topic.asp?topicid=631045  

or in WeDelphi.com with screenshots!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 ddrfan (若苗瞬) ▲▲▲▲▲ -
普通会员
2022/7/7 10:02:35
8楼: Hi,@emailx45
thx remind me again:)
however I can't make it work, 
after following the steps on my Win10 laptop.

1) sudo apt install X11-apps
2) edit .bashrc and add the line at last: 
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0



and restart WSL and even Windows. 

I check the conf by:
> cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.27.16.1

and check with:
~> echo $DISPLAY
172.27.16.1:0

and ping it:
 ~> ping 172.27.16.1
PING 172.27.16.1 (172.27.16.1) 56(84) bytes of data.
64 bytes from 172.27.16.1: icmp_seq=1 ttl=128 time=0.258 ms
64 bytes from 172.27.16.1: icmp_seq=2 ttl=128 time=0.252 ms
64 bytes from 172.27.16.1: icmp_seq=3 ttl=128 time=0.844 ms
64 bytes from 172.27.16.1: icmp_seq=4 ttl=128 time=1.50 ms
^C
--- 172.27.16.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3083ms
rtt min/avg/max/mdev = 0.252/0.712/1.496/0.512 ms


the error is:
Unable to init server: Could not connect: Connection refused



sth is wrong but I don't know it...T_T
----------------------------------------------
Bye bye DDRFAN...
作者:
男 ddrfan (若苗瞬) ▲▲▲▲▲ -
普通会员
2022/7/7 10:08:58
9楼: oh, I saw what I missed...
I'd try it again by install windows' Xserver.
----------------------------------------------
Bye bye DDRFAN...
作者:
男 ddrfan (若苗瞬) ▲▲▲▲▲ -
普通会员
2022/7/7 10:29:28
10楼: Oops I did it again, easy peasy japanesy :)
此帖子包含附件:
PNG 图像
大小:1.51M
----------------------------------------------
Bye bye DDRFAN...
作者:
男 ddrfan (若苗瞬) ▲▲▲▲▲ -
普通会员
2022/7/7 10:32:02
11楼: It works! as above.
but Chinese characters don't show nice...
----------------------------------------------
Bye bye DDRFAN...
作者:
男 ddrfan (若苗瞬) ▲▲▲▲▲ -
普通会员
2022/7/7 12:07:47
12楼: Because Windows terminal support Chinese.
and before test GUI, the terminal is the only way.
so I forget to let WSL's Ubuntu support Chinese too...

after check locale and install Chinese support and fonts...
it works fine now.

nice~
此帖子包含附件:
PNG 图像
大小:397.1K
----------------------------------------------
Bye bye DDRFAN...
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/7 22:27:15
13楼: @ddrfan 

if your Linux using Chinese by default, then your "chars" it's ok!
all day, a new day (same that be night now :))
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 ddrfan (若苗瞬) ▲▲▲▲▲ -
普通会员
2022/7/9 14:20:22
14楼: @emailx45

The linux in WSL is neither Chinese nor other language by default.
it's C.UTF8 (a default lang and UTF8 charset).
at least my Ubuntu20 in WSL is in that way.

theoretically, it can not display Chinese chars (with out language support and font installed).

so if the Linux is in a VM, like VMware. and we use it via VMware's UI directly, no Chinese char with be readable.

but the Linux in WSL? the only way to acces it, is to use a terminal (before GUI way works).and if this “terminal” support Chinese, the chars displayed nice.

as we all know, the“terminals”we use today is not a physical monitor. 
they are all Terminal Emulator Programs. and if they provide language support, chars will be OK. even the WSL linux don't support that language.

because the char's hexadecimal code are not changed.

and also cause encoding problem, like famous“锟斤拷”in Chinese...
it's another story by GBxxx encoding (China's legal standard) versus Unicode encoding.

-----

The above is really long for my pool English.
hope guys may understand :)
----------------------------------------------
Bye bye DDRFAN...
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/16 5:42:25
15楼: here in Brazil, too! same "Locale" by default! = UTF8
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行265.625毫秒 RSS