Go+Windows+Audio

xuanbao · · 1227 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;ve tried to get access to Windows audio from Go program but failed. That I did below: 1. Downloaded and built Portaudio (it&#39;s open audio I/O library <a href="http://portaudio.com/" rel="nofollow">http://portaudio.com/</a>). So I&#39;ve built that with Visual Studio and got .dll file. 2. Downloaded Go wrapper for Portaudio - ( github.com/gordonklaus/portaudio ) 3. Made simple Go file with example from wrapper above to test. 4. Go build.</p> <p>So Go couldn&#39;t build that. As far as I understand that&#39;s tried to build portaudio from source with cgo. I&#39;ve installed MinGW (gcc for Windows) and pkg-config but last one can&#39;t find portaudio-2.0.pc file. Once I&#39;ve renamed portaudio-2.0.pc.in to portaudio-2.0.pc however it shows gcc error: &#34;gcc: error: @THREAD_CFLAGS@: No such file or directory&#34;</p> <p>So any ideas, help?</p> <hr/>**评论:**<br/><br/>evilissimo: <pre><pre><code> #cgo pkg-config: portaudio-2.0 </code></pre> <p>remove that from the portaudio wrapper and replace it with:</p> <pre><code> #cgo LDFLAGS: -lportaudio </code></pre> <p>that might work, however you might have to add the path to the library via -L on the LDFLAGS</p></pre>xlab_is: <pre><p>Nice try, but it actually should be much more</p> <pre><code>$ pkg-config --cflags portaudio-2.0 -mthreads -IC:/MinGW/msys/1.0/local/include $ pkg-config --libs portaudio-2.0 -LC:/MinGW/msys/1.0/local/lib -lportaudio -lwinmm -lm -lole32 -luuid </code></pre></pre>Sythe2o0: <pre><p>self plug: I wrote a small thing to avoid mucking around with c code that has some limited audio functionality for windows <a href="https://bitbucket.org/StephenPatrick/go-winaudio" rel="nofollow">here</a></p> <p>But I avoid having any kind of c code in my go projects.</p></pre>xlab_is: <pre><p>I got this working fine on Windows 7 32-bit in 10 minutes.</p> <p>1) First, install MinGW, I expect it be somewhere in C:\MinGW and run MSYS 1.0</p> <p>2) Follow this answer: <a href="http://stackoverflow.com/a/26453379" rel="nofollow">http://stackoverflow.com/a/26453379</a> to get pkg-config working</p> <p>3) Download PortAudio sources (<a href="http://www.portaudio.com/download.html" rel="nofollow">http://www.portaudio.com/download.html</a>) in somewhere like C:\dev\portaudio</p> <p>4) Go to sources and do ./configure &amp;&amp; make &amp;&amp; make install</p> <p>It should notice pkg-config existence while configuring and it should print after installation that it copied pkg-config data as well, see my screenshots: <a href="https://cl.ly/140k3m3S2Z1L/Screen%20Shot%202016-11-08%20at%2020.51.37.png" rel="nofollow">https://cl.ly/140k3m3S2Z1L/Screen%20Shot%202016-11-08%20at%2020.51.37.png</a> and <a href="https://cl.ly/3B0d1K312y27/Screen%20Shot%202016-11-08%20at%2020.58.05.png" rel="nofollow">https://cl.ly/3B0d1K312y27/Screen%20Shot%202016-11-08%20at%2020.58.05.png</a></p> <p>5) Don&#39;t forget to use <code>PKG_CONFIG_PATH</code>, everything should go smooth now, example:</p> <p><code> $ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig go get github.com/xlab/alac-go/cmd/alac-player </code></p></pre>comrade-jim: <pre><p>I use Linux as my development environment and if you&#39;re going to be compiling software the best solution I&#39;ve found is to install a stable Linux distro (like Ubuntu) and then install LXC, and then create a gentoo container using LXC. Gentoo is a distribution where all software is compiled by the package manager. Even when some packages aren&#39;t included in portage, because gentoo has most of the tools needed to compiles packages, it hardly ever has any issues when you need to compile manually. </p> <p>I still use Windows on my gaming rig, but Linux is just the superior option when it comes to dev environments unless you want to jump through hoops all day on Windows. Even Microsoft has admitted than Linux is a better development environment than Windows, which is why they now ship with a Linux compatibility layer (which is still pretty buggy btw). </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1227 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传