Comments (11)
Sorry for the slow reply; somehow I was not watching my own repo :-/
Apparently cgo is disabled by default when cross-compiling. You'll have to add CGO_ENABLED=1 to your command line.
from portaudio.
just install portaudio with brew (or compile from source) and you can build the examples.
from portaudio.
➜ examples git:(master) env GOOS=windows GOARCH=386 go build stereoSine.go
stereoSine.go:4:2: no buildable Go source files in /go/src/github.com/gordonklaus/portaudio
it is definitely able to build for mac, but it is not able to build for windows...
any suggestions?
from portaudio.
Okay... still no luck :)
i wonder if i need to put somewhere some portaudio-for-windows headers or .lib files or whatever...
➜ examples git:(master) ✗ env CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build stereoSine.go
go build github.com/gordonklaus/portaudio: no buildable Go source files in /go/src/github.com/gordonklaus/portaudio
from portaudio.
Yeah, you will eventually need to have built portaudio for windows (which I'm afraid I can't help you with). But at the moment that doesn't seem to be the problem. Have you already verified that there actually are source files in /go/src/github.com/gordonklaus/portaudio
? To be honest you'll have a better chance resolving this, and faster, on golang-nuts; those folks are a helpful bunch.
from portaudio.
@rshmelev Did you get this working? I'm having a nightmare trying to access portaudio in Windows from Go. I found portaudio precompiled DLLs but still cannot get it to work on Windows.
from portaudio.
Definitely not an ideal solution, but I was able to get PortAudio working on Windows using the following procedures:
- Compile or the appropriate DLL and move it into both your project's directory and the
portaudio
package directory - Modify the
cgo
directives inportaudio.go
to the following:
/*
#cgo LDFLAGS: -L${SRCDIR} -lportaudio
#include "portaudio.h"
extern PaStreamCallback* paStreamCallback;
*/
import "C"
In step 2, you can modify the path after -L
and the library name after -l
to match your desired library location and filename.
The reason this is a sloppy fix is because a) the dynamic library must be distributed with your compiled program or it won't work (statically linking might be better, still working that out) and b) it requires modification to the package source after downloading.
from portaudio.
Maybe it's time for docker?
Big advantage is that you can also compile for other architectures like aarch64!
You may be interested in this step-by-step tutorial which really helped me.
According to above, You could create golang:1.17-bullseye
Dockerfile with architecture and compiler (for windows / linux) of your choice (as debian bullseye has multiarch support and multiarch libs)
However be careful with musl (glib alternative) lib linux distros like alpine linux according to this
from portaudio.
I have explained in a blog post how to cross compile golang cgo projects using docker. You can find in a dedicated repository the dockerfiles with the cross compiling toolchains setup for for several operating systems and architectures. The project remoteAudio is actually using @gordonklaus's fantastic go binding for portaudio!
from portaudio.
@dh1tw I tried your configuration but this is still a problem cross compiling from a mac m2 to linux for raspi using armhf
from portaudio.
@talksik, a few more details or a log would help
from portaudio.
Related Issues (20)
- Opening a stream with a framesPerBuffer of 0 causes a buffer underrun and a stutter HOT 1
- "Unknow Error" in MacOS Big Sur HOT 1
- Get nothing using OpenDefaultStream in the latest mac os Big Sur. HOT 1
- unable to open on a device HOT 6
- Does not appear to work with PipeWire HOT 3
- Running mp3 example with hajimehoshi/go-mp3 library HOT 5
- Playing Opus stream causes playback half speed HOT 3
- Issues installing on Windows HOT 5
- how can I use go get ? HOT 2
- GEt live audio from microphone HOT 2
- Resulting windows apps built with golang 1.17.5 crash on startup. HOT 1
- windows dll HOT 4
- MacOS compile Windows error HOT 2
- Example `play.go` not working correctly HOT 1
- "go install <your portaudio module>" doesn't work HOT 3
- play.go example aiff file sounds "strange" HOT 2
- How do I get microphone level? [HELP] HOT 2
- fatal error: checkptr: pointer arithmetic result points to invalid allocation HOT 7
- examples/record.go not working keep getting panice error
- The built binary file cannot run another Windows HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from portaudio.