Coder Social home page Coder Social logo

cross-compiling about portaudio HOT 11 CLOSED

gordonklaus avatar gordonklaus commented on July 24, 2024 2
cross-compiling

from portaudio.

Comments (11)

gordonklaus avatar gordonklaus commented on July 24, 2024 2

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.

helinwang avatar helinwang commented on July 24, 2024

just install portaudio with brew (or compile from source) and you can build the examples.

from portaudio.

rshmelev avatar rshmelev commented on July 24, 2024

➜ 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.

rshmelev avatar rshmelev commented on July 24, 2024

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.

gordonklaus avatar gordonklaus commented on July 24, 2024

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.

nkev avatar nkev commented on July 24, 2024

@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.

chxmbley avatar chxmbley commented on July 24, 2024

Definitely not an ideal solution, but I was able to get PortAudio working on Windows using the following procedures:

  1. Compile or the appropriate DLL and move it into both your project's directory and the portaudio package directory
  2. Modify the cgo directives in portaudio.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.

BigB84 avatar BigB84 commented on July 24, 2024

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.

dh1tw avatar dh1tw commented on July 24, 2024

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.

talksik avatar talksik commented on July 24, 2024

@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.

dh1tw avatar dh1tw commented on July 24, 2024

@talksik, a few more details or a log would help

from portaudio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.