Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Windows. #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

icm7216
Copy link

@icm7216 icm7216 commented Oct 16, 2021

Added a library for Windows to ffi_lib.
In a Windows RubyInstaller2 environment, fortunately the portaudio librarie is available through the MSYS2 repository.

install mingw-w64-x86_64-portaudio package.

>ridk exec pacman -S mingw-w64-x86_64-portaudio

The ridk tool is a helper tool to manage the runtime environment of RubyInstaller2. It can be used in cmd.

@kojix2
Copy link

kojix2 commented Oct 18, 2021

Hi.
I think this is a good pull request.
Maybe, you can specify

spec.metadata['msys2_mingw_dependencies'] = 'portaudio'

and portaudio will be installed automatically.

See example below.
https://github.com/red-data-tools/GR.rb/blob/7ce2d5b2f7139248361a16fff4199c9cfa704743/ruby-gr.gemspec#L32

If you don't mind, could you try this to see if it works? And if it does, could you try adding a commit?

@kojix2
Copy link

kojix2 commented Oct 18, 2021

In my environment, it seems that it is not libportaudio-2, but simply libportaudio.

@kojix2
Copy link

kojix2 commented Oct 18, 2021

See https://github.com/kojix2/ffi-portaudio/commits/support-for-windows
This simple test now passes, but the examples do not seem to work on Windows...

@icm7216
Copy link
Author

icm7216 commented Oct 19, 2021

@kojix2 Thanks for all the advice.
I will do some more research.

@icm7216
Copy link
Author

icm7216 commented Oct 19, 2021

@kojix2, your suggestion worked well in my environment, so I'll add a commit.
Thanks!

s.metadata['msys2_mingw_dependencies'] = 'portaudio'

@icm7216
Copy link
Author

icm7216 commented Oct 19, 2021

@kojix2, What is your portaudio dll version?

I found that different versions of dlls are installed depending on the state of the msys package database after ruby is installed.
My environment was still installed with rubyinstaller2.
I think it is better to write both 'libportaudio' and 'libportaudio-2' in ffi_lib.

ffi_lib ['portaudio', 'libportaudio.so.2', 'libportaudio', 'libportaudio-2']

For more details, please refer to the following

C:\Users\icm7216>ruby --version
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x64-mingw32]

enable ridk tool commands

C:\Users\icm7216>ridk enable

pacman version.

C:\Users\icm7216>pacman -Sl | grep 'pacman '
msys pacman 6.0.0-5 [インストール済み]

portaudio version.

C:\Users\icm7216>pacman -Qs portaudio
local/mingw-w64-x86_64-portaudio 190600_20161030-3
    A free, cross-platform, open source, audio I/O library
    (mingw-w64)
C:\Users\icm7216>pacman -Qi mingw-w64-x86_64-portaudio
名前                   : mingw-w64-x86_64-portaudio
バージョン             : 190600_20161030-3
説明                   : A free, cross-platform, open source, audio
                         I/O library (mingw-w64)
アーキテクチャ         : any
URL                    : http://www.portaudio.com
ライセンス             : custom
グループ               : なし
提供                   : なし
依存パッケージ         : mingw-w64-x86_64-gcc-libs
提案パッケージ         : なし
必要パッケージ         : なし
任意パッケージ         : なし
衝突パッケージ         : なし
置換パッケージ         : なし
インストール容量       : 723.00 KiB
パッケージ作成者       : Alexey Pavlov <alexpux@gmail.com>
ビルド日時             : 2017年06月12日 19時57分44秒
インストール日時       : 2021年10月10日 15時52分02秒
インストール方法       : 明示的にインストール
インストールスクリプト : No
検証方法               : 署名

List of the files installed by poartaudio.
I got libportaudio-2.dll

C:\Users\icm7216>pacman -Ql mingw-w64-x86_64-portaudio
mingw-w64-x86_64-portaudio /mingw64/
mingw-w64-x86_64-portaudio /mingw64/bin/
mingw-w64-x86_64-portaudio /mingw64/bin/libportaudio-2.dll
mingw-w64-x86_64-portaudio /mingw64/include/
mingw-w64-x86_64-portaudio /mingw64/include/portaudio.h
mingw-w64-x86_64-portaudio /mingw64/lib/
mingw-w64-x86_64-portaudio /mingw64/lib/libportaudio.a
mingw-w64-x86_64-portaudio /mingw64/lib/libportaudio.dll.a
mingw-w64-x86_64-portaudio /mingw64/lib/pkgconfig/
mingw-w64-x86_64-portaudio /mingw64/lib/pkgconfig/portaudio-2.0.pc

So I upgraded to the package.

C:\Users\icm7216>pacman -Syu
:: パッケージデータベースの同期中...
 mingw32              1465.2 KiB   174 KiB/s 00:08 [##########] 100%
 mingw64              1472.4 KiB   179 KiB/s 00:08 [##########] 100%
 ucrt64               1614.9 KiB   189 KiB/s 00:09 [##########] 100%
 clang64              1457.4 KiB   179 KiB/s 00:08 [##########] 100%
 msys                  387.5 KiB  95.0 KiB/s 00:04 [##########] 100%
:: コアシステムの更新を開始...
警告: 続行する前に他の MSYS2 プログラムを終了してください
依存関係を解決しています...
衝突するパッケージがないか確認しています...

パッケージ (5) filesystem-2021.06-2  mintty-1~3.5.1-1
               msys2-runtime-3.2.0-15  pacman-6.0.1-3
               pacman-mirrors-20210902-1

合計ダウンロード容量:         9.38 MiB
合計インストール容量:        45.57 MiB
最終的なアップグレード容量:   0.21 MiB

:: インストールを行いますか? [Y/n]

--- snip ---

After upgrading, restart the terminal, and enable the ridk tool.

C:\Users\icm7216>ridk enable

Search for the newer version of portaudio packages.

C:\Users\icm7216>pacman -Sl | grep 'mingw-w64-x86_64-portaudio'
mingw64 mingw-w64-x86_64-portaudio 1~19.7.0-2 [インストール済み: 190600_20161030-3]

install the new portaudio.

C:\Users\icm7216>pacman -S mingw-w64-x86_64-portaudio
依存関係を解決しています...
衝突するパッケージがないか確認しています...

パッケージ (1) mingw-w64-x86_64-portaudio-1~19.7.0-2

合計ダウンロード容量:        0.17 MiB
合計インストール容量:        0.86 MiB
最終的なアップグレード容量:  0.16 MiB

:: インストールを行いますか? [Y/n] y
:: パッケージを取得します...
 mingw-w64-x86_64...   176.6 KiB  74.2 KiB/s 00:02 [################] 100%
(1/1) キーリングのキーを確認                       [################] 100%
(1/1) パッケージの整合性をチェック                 [################] 100%
(1/1) パッケージファイルのロード                   [################] 100%
(1/1) ファイルの衝突をチェック                     [################] 100%
(1/1) 空き容量を確認                               [################] 100%
:: パッケージの変更を処理しています...
(1/1) 更新 mingw-w64-x86_64-portaudio              [################] 100%

Search for locally installed poartaudio package.

C:\Users\icm7216>pacman -Qi mingw-w64-x86_64-portaudio
名前                   : mingw-w64-x86_64-portaudio
バージョン             : 1~19.7.0-2
説明                   : A free, cross-platform, open source, audio I/O
                         library (mingw-w64)
アーキテクチャ         : any
URL                    : http://www.portaudio.com
ライセンス             : custom
グループ               : なし
提供                   : なし
依存パッケージ         : mingw-w64-x86_64-gcc-libs
提案パッケージ         : なし
必要パッケージ         : なし
任意パッケージ         : なし
衝突パッケージ         : なし
置換パッケージ         : なし
インストール容量       : 881.84 KiB
パッケージ作成者       : CI (msys2-autobuild/be1f0f71/1060384131)
ビルド日時             : 2021年07月24日 01時58分33秒
インストール日時       : 2021年10月20日 00時26分52秒
インストール方法       : 明示的にインストール
インストールスクリプト : No
検証方法               : 署名

A list of the files installed by the portaudio package.

C:\Users\icm7216>pacman -Ql mingw-w64-x86_64-portaudio
mingw-w64-x86_64-portaudio /mingw64/
mingw-w64-x86_64-portaudio /mingw64/bin/
mingw-w64-x86_64-portaudio /mingw64/bin/libportaudio.dll
mingw-w64-x86_64-portaudio /mingw64/include/
mingw-w64-x86_64-portaudio /mingw64/include/pa_win_ds.h
mingw-w64-x86_64-portaudio /mingw64/include/pa_win_wasapi.h
mingw-w64-x86_64-portaudio /mingw64/include/pa_win_waveformat.h
mingw-w64-x86_64-portaudio /mingw64/include/pa_win_wdmks.h
mingw-w64-x86_64-portaudio /mingw64/include/pa_win_wmme.h
mingw-w64-x86_64-portaudio /mingw64/include/portaudio.h
mingw-w64-x86_64-portaudio /mingw64/lib/
mingw-w64-x86_64-portaudio /mingw64/lib/cmake/
mingw-w64-x86_64-portaudio /mingw64/lib/cmake/portaudio/
mingw-w64-x86_64-portaudio /mingw64/lib/cmake/portaudio/portaudioConfig.cmake
mingw-w64-x86_64-portaudio /mingw64/lib/cmake/portaudio/portaudioConfigVersion.cmake
mingw-w64-x86_64-portaudio /mingw64/lib/cmake/portaudio/portaudioTargets-release.cmake
mingw-w64-x86_64-portaudio /mingw64/lib/cmake/portaudio/portaudioTargets.cmake
mingw-w64-x86_64-portaudio /mingw64/lib/libportaudio.a
mingw-w64-x86_64-portaudio /mingw64/lib/libportaudio.dll.a
mingw-w64-x86_64-portaudio /mingw64/lib/pkgconfig/
mingw-w64-x86_64-portaudio /mingw64/lib/pkgconfig/portaudio-2.0.pc
mingw-w64-x86_64-portaudio /mingw64/share/
mingw-w64-x86_64-portaudio /mingw64/share/doc/
mingw-w64-x86_64-portaudio /mingw64/share/doc/portaudio/
mingw-w64-x86_64-portaudio /mingw64/share/doc/portaudio/LICENSE.txt
mingw-w64-x86_64-portaudio /mingw64/share/doc/portaudio/README.md

I got libportaudio.dll which is the same dll name as @kojix2

@kojix2
Copy link

kojix2 commented Oct 19, 2021

@icm7216
Thank you for your help.
Yes. I think we should include both libportaudio and libportaudio-2.

@icm7216
Copy link
Author

icm7216 commented Oct 19, 2021

I added both library bportaudio and libportaudio-2 in ffi_lib.

Thanks @kojix2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants