Agigi Wang
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    Wine的使用方法與心得 === ###### tags: `程式相關` `財金相關` # Wine基本說明 - Wine的原理是去破解`C:\windows\system32`之下主要的DLL檔的功能,再自己重新implement這些DLL檔,使得所有的Windows程式在執行時call到這些DLL檔時,背後能轉換成POSIX的函式庫,來完成DLL檔原本的工作!!而這樣子比起虛擬機來講,就能少掉虛擬機的那一層虛擬硬體層的overhead了! - 但是面對`.Net Framework`和`Visual C++可轉散發套件`時,Wine選擇不自己implement這二者的DLL檔,而是讓使用者自己去安裝Windows版的`.Net Framework`和`Visual C++可轉散發套件`的安裝檔!我想這是因為這二者的DLL檔都比較上層,它們的功能全部都是透過去call更底層的`KERNEL32`和`ntdll`之類的DLL檔來完成自己的功能!而更底層的DLL檔Wine都已經自己implement完並且轉換成POSIX了! - 而有一些Wine已經寫好的DLL檔並不那麼底層,像是`winhttp`和`wininet`,它們並沒有那麼底層,而且它們也是透過call更底層的DLL檔來完成它們自己的功能的!所以像這種DLL檔我們也有機會選擇安裝Windows原生的安裝檔來把Wine版的`winhttp`和`wininet`換掉,改成Windows版的`winhttp`和`wininet`!而這就是DLL檔所謂的`builtin (內建)`和`native (原生)`的差別了!`builtin (內建)`是指Wine版的DLL,而`native (原生)`是指Windows版的DLL!(`builtin`和`native`意義太相近了!記法是:`Windows原生DLL檔`很明顯就是在指Windows版的DLL檔!) - 透過Wine的`winecfg`指令可以設定已經安裝過Windows版的DLL檔,使用者要選擇用Wine版的或Windows版的、或是誰的優先於另一個人的、或是不要發揮功用之類的。 - `winecfg`還可以設定Wine目前虛擬的Windows版本是多少,不過實際設定之後感覺作用不大。 - 執行Wine時建議是要在有XWindow的環境下執行!(是有點麻煩沒錯!) - Wine預設會把整個Windows的檔案系統安裝在`~/.wine`裡!進到`~/.wine/drive_c/`裡,你可以發現精簡版的Windows C槽的資料夾都在這裡!你可以: - 直接執行`wine putty.exe`來從無到有生出一個`~/.wine`資料夾後,再執行`putty.exe`在XWindow下秀出putty! - 執行`wineboot`來從無到有生出一個`~/.wine`資料夾!但不會執行任何程式。**(強烈建議先這樣做!!!)** - 執行`WINEPREFIX=~/.wine32 WINEARCH=win32 wineboot`來從無到有生出一個`~/.wine32`資料夾!而且`~/.wine32`裡是是32位元的Windows環境!(雖然這只對64位元版的Wine有差而已) - 嫌每一次前面都有打`WINEPREFIX=~/.wine32 WINEARCH=win32`麻煩的話,可以先`export`一次變數,之後就不用再每次都打這麼長一串了! ``` $ export WINEPREFIX=~/.wine32 $ export WINEARCH=win32 ``` - 在32位元下的Ubuntu下安裝32位元版的Wine就可以不用這麼麻煩每次都要先`export`了!**(強烈建議!!!)** - 透過另一個方便的第三方工具`winetricks`可以輕鬆地下載適合的安裝檔並且只挑其中特定的DLL檔出來蓋掉Wine版的DLL檔。此外`winetricks`還可以方便地安裝`.Net Framework`和`Visual C++可轉散發套件`,而近來的`wiretricks`更可以直接幫你安裝Windows遊戲或Office等!真的狂! - 不過要注意!一定要直接從Github下載`winetricks`的bleeding edge版!而不能用`apt install`安裝!`apt install`的是2014年版的`winetricks`!很多東西下載不到,而且安裝檔的相容性也沒有顧到! - 安裝`winetricks`: ``` $ wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks $ chmod +x ./winetricks ``` - 使用`winetricks`: ``` $ winetricks list-all (列出所有可以安裝的套件) $ winetricks list-installed (列出所有已經安裝的套件) $ winetricks vcrun2010 (安裝VC++2010的可轉散發套件) $ winetricks vcrun2015 (安裝VC++2015的可轉散發套件) $ winetricks dotnet40 (安裝.Net Framework 4.0) $ winetricks winhttp (安裝Windows 2000 SP4版的winhttp.dll,測試後沒有用故不會裝) $ winetricks wininet (安裝Windows 7 SP1版的wininet.dll,測試後沒有用故不會裝) $ winetricks wininet_win2k (安裝Windows 2000 SP4版的wininet.dll,測試後沒有用故不會裝) $ winetricks win7 (設定.wine的環境為Windows 7,測試後沒有感覺差別故不會裝) $ winetricks winxp (設定.wine的環境為Windows XP,測試後沒有感覺差別故不會裝) ``` - 若要debug查看執行`wine putty.exe`時DLL層的執行細節的話,可以使用`WINEDEBUG`變數來印出更多細節!([`WINEDEBUG`官方說明](https://wiki.winehq.org/Debug_Channels)) ``` $ WINEDEBUG=+relay,+seh,+tid wine ./putty.exe > ~/putty.log 2>&1 ``` - 執行`wine control`可以叫出控制台!不過只有三個圖示而已,看得出來這個控制台是Wine自製的!然後要匯入根憑證檔要來這個控制台匯入,而不是執行`wine ./iexplorer.exe`打開IE5然後找選項匯入! - 執行`wine uninstaller`可以叫出剛剛控制台三個圖示之一的解除安裝管理員!裡面可以看到`winetricks`裝過的套件!不曉得它解安裝`winetricks`裝過的套件之後,執行`winetricks list-installed`會不會還看得到該套件,以及該套件是否還有作用。(我沒試那麼深入) - Wine目前連`GTA 5`也可以執行了!(`GTA 5`是Wine支援度最高級的遊戲,是`白金級`的支援程度!) 所以幸運的是,在連日來的熬夜之下,**我已經確定群益的API `SKCOM.dll`也可以利用Wine在Linux上執行了!** ------ # 安裝說明 - 建議使用Ubuntu 32位元的作業系統來安裝Wine,因為Wine目前64位元的支援很差,它主要是以執行32位元的Windows程式為主!而且Ubuntu 64位元的函式庫正常來講我都會安裝得很完整;但是32位元的函式庫我就幾乎不會裝了,就無法確定Wine是否會因為call不到底層32位元的函式庫而運作異常! - 建議是透過compile Wine原始碼的方式來安裝Wine,而非加入Wine官方PPA再執行`apt install`來安裝Wine!一樣也是為了避免Ubuntu 32位元的函式庫我裝得不夠完整!Wine的`configure`非常強大!它會在執行完後歸納出系統會因為缺少什麼函式庫的開發套件而會有什麼功能執行不到!(仔細想想,我在用原始碼安裝Wine之後,`fixme`出現的次數變少非常非常多!原來`fixme`不一定是提醒Wine的開發者而已!) ------ # 安裝步驟 - 基本上來講,我會安裝以下的套件來初始化我剛裝好的Ubuntu 16.04 ``` $ sudo apt update; apt upgrade $ sudo apt install openssh-client openssh-server vim python-software-properties software-properties-common gcc g++ vim subversion automake autoconf perl patch build-essential libtool doxygen bison flex zlib1g-dev gperf tofrodos wget curl screen git samba vsftpd bash-completion ftp colordiff libkrb5-dev rar unrar unzip vnstat libssl-dev ``` - 用root帳號登入Ubuntu環境! - 先把Wine的git repository上的code拉下來! ``` $ mkdir -pv /root/packages ; cd /root/packages $ time git clone https://github.com/wine-mirror/wine ``` - 先執行一次`./configure` ``` $ cd ./wine $ time ./configure ``` - 應該會看到以下的訊息! ``` checking for X... no configure: error: X development files not found. Wine will be built without X support, which probably isn't what you want. You will need to install development packages of Xlib at the very least. Use the --without-x option if you really want this. ``` - 若只有安裝X Windows的library而已的話,可能大概會看到以下類似的Info訊息和Warning訊息!這代表SOP那一篇文章裝的套件還不夠多! ``` configure: MinGW compiler not found, cross-compiling PE files won't be supported. configure: libhal development files not found, no legacy dynamic device support. configure: libSDL2 development files not found, SDL2 won't be supported. configure: libFAudio development files not found, XAudio2 won't be supported. configure: libvulkan and libMoltenVK development files not found, Vulkan won't be supported. configure: vkd3d development files not found (or too old), Direct3D 12 won't be supported. configure: WARNING: No OpenGL library found on this system. OpenGL and Direct3D won't be supported. configure: WARNING: libxml2 development files not found (or too old), XML won't be supported. configure: WARNING: libxslt development files not found, xslt won't be supported. configure: WARNING: libgnutls development files not found, no schannel support. configure: WARNING: libjpeg development files not found, JPEG won't be supported. configure: WARNING: No sound system was found. Windows applications will be silent. configure: Finished. Do 'make' to compile Wine. ``` - 安裝所有剩下所需的套件以盡量減少部分Info訊息和所有Warning訊息!(我是參考[這一篇](http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?topic_id=106690&forum=1&menumode=1)的!重要!) ``` $ time apt install gnome-devel libx11-dev flex bison qt4-qmake libjpeg-dev libxslt1-dev libglu1-mesa-dev freeglut3-dev prelink libasound2-dev libfreetype6-dev libpng-dev libxml2-dev libxrender-dev libgl1-mesa-dev libgphoto2-dev libmpg123-dev libtiff-dev libpulse-dev liblcms2-dev libcapi20-dev libldap-dev libopenal-dev libv4l-dev libsane-dev libcups2-dev libgsm1-dev libosmesa6-dev libgnutls28-dev libpcap0.8-dev oss4-dev libcdk5-dev libgstreamer-plugins-base1.0-dev libarrayfire-opencl-dev $ time apt install libsdl2-dev libvulkan-dev ``` - 清除一下apt-get抓下來的殘餘檔 ``` $ apt clean ``` - 接下來再執行`./configure`一次! ``` $ time ./configure ``` - 你會發現Info訊息和所有Warning訊息大概只剩下這樣,這樣就差不多了。 ``` configure: MinGW compiler not found, cross-compiling PE files won't be supported. configure: libhal development files not found, no legacy dynamic device support. configure: libFAudio development files not found, XAudio2 won't be supported. configure: vkd3d development files not found (or too old), Direct3D 12 won't be supported. ``` - 接下來編譯並且安裝它!編譯的過程會花一些時間!(大約42分鐘) ``` $ time make $ time make install ``` - 接下來安裝好用的`winetricks`!直接從github wget下來就可以用了! ``` $ mkdir -pv /opt/bin ; cd /opt/bin $ wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks $ chmod +x ./winetricks $ ./winetricks -V 20190615-next - sha256sum: 47304e177f259d6f9c05af01ab42c06531fd8a9716e2751d2fadcd664130feea ``` - 安裝結束!大功告成! ------ # 使用心得 - `winhttp` win7版有bug,所以`winetricks`目前不支援!詳情請直接打開`winetricks`找到安裝`winhttp`的那一行! - 其他有關於使用Wine來跑群益API寫出來的程式的心得,請參考另一篇文章「[使用Wine來跑群益API](https://hackmd.io/Tz2YYvOLTyG9FU0skkWs-Q)」!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully