2020/5/19

MinGW, msys

隔了這麼多年,終於又安裝MinGW 了。(世界所有的 RD 們,什麼時候才要全面轉為 Linux ?)

現在安裝簡單多了,就 download install program,執行安裝,完成後,出現 package selection dialog,選要的。 (base system msys & MinGW)
Default 安裝是 C:\MinGW
所以要把 C:\MinGW\bin 加到 system path 中.
這部份還好,都是 compile toolchain,不會影響到 windows command。
其他 shell command 在 C:\MinGW\msys\1.0\bin,所以不能加到 system path 中。
寫一個 batch 檔setmsyspath.bat,需要得時候再 run:
set PATH=%PATH%;C:\MinGW\msys\1.0\bin
* 用字串符號括起來的話,反而會失效。
進入command 後,執行batch,就會出現新的 path.

其實,msys\bin 下有一個 batch: msys.bat,執行後就會設好一些環境,然後 run shell.exe,讓環境更像 unix


update: 2023/10/17

windows10 之後的msys2 support 更好了。
安裝完會開啟幾個default compiler 64, llvm.. 的環境。
之後安裝 package 不用再找以前難用的 msys,改用pacman
就像 apt 依樣,在msys 的console 下 pacman -S package-name 就可以了。

另外因為 msys2 focus 在console program,所以所有 X 的program 都不能run。
所以 要 將遠端 server 的 X client 導入的話,依樣要在windows 下 run 一個 Xserver ,像xming 或是 VcXsrv
然後用 ssh -X 連線,之後還要export DISPLAY=localhost:0 之後,才會正確的把 遠端 server 的 X forward 到 local 端。

在 msys 的 console 先 export DISPLAY=localhost:0,之後用 ssh -Y 連線後,會自動設置 DISPLAY 變數,這時候就會把 X protocol forward 回來 Xserver 上。

-X 和 -Y 的差異。man ssh 的說明:
     -X      Enables X11 forwarding.  This can also be specified on a per-host basis in a configuration file.

             X11 forwarding should be enabled with caution.  Users with the ability to bypass file permissions on the remote host (for the user's X authorization database)
             can access the local X11 display through the forwarded connection.  An attacker may then be
             able to perform activities such as keystroke monitoring.

             For this reason, X11 forwarding is subjected to X11 SECURITY extension restrictions by default.  Please refer to the ssh -Y option and the ForwardX11Trusted 
             directive in ssh_config(5) for more information.

             (Debian-specific: X11 forwarding is not subjected to X11 SECURITY extension restrictions by default, because too many programs currently crash in this mode.  
             Set the ForwardX11Trusted option to “no” to restore the upstream behaviour.  This may change in future depending on client-side improvements.)

     -Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.

             (Debian-specific: In the default configuration, this option is equivalent to -X, since ForwardX11Trusted defaults to “yes” as described above.  
             Set the ForwardX11Trusted option to “no” to restore the upstream behaviour.  This may change in future depending on client-side improvements.)

沒有留言:

張貼留言