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

Issues installing on Windows #47

Closed
Aidan-OS opened this issue Oct 1, 2021 · 5 comments
Closed

Issues installing on Windows #47

Aidan-OS opened this issue Oct 1, 2021 · 5 comments

Comments

@Aidan-OS
Copy link

Aidan-OS commented Oct 1, 2021

Hi,

I am trying to attach to audio streams on windows with go and have found many sources pointing to this package but I am having issues when running the go get command. Here are the steps I have taken so far:

  1. Downloaded the source for PortAudio
  2. Followed the instructions found here: https://github.com/PortAudio/portaudio/wiki/Notes_about_building_PortAudio_with_MinGW
  3. Added my PortAudio path to my PKG_CONFIG_PATH environment variable
  4. Run go get github.com/gordonklaus/portaudio

When I run the final command I get this error:

# github.com/gordonklaus/portaudio
C:\Users\user\go\pkg\mod\github.com\gordonklaus\portaudio@v0.0.0-20200911161147-bb74aa485641\portaudio.go:16:10: fatal error: portaudio.h: No such file or directory
   16 | #include <portaudio.h>
      |          ^~~~~~~~~~~~~
compilation terminated.

When looking at the file mentioned here I find that line 16 is contained in a multi line comment, so the fact that it is complaining makes no sense to me. Is there something that I have done wrong?

@gordonklaus
Copy link
Owner

Hi Aidan,

I'm not using Windows but maybe I can help.

Is there not a way to install a pre-compiled PortAudio on MinGW? I see there are some package managers, but I don't know if there is a package for PortAudio.

I suspect you're missing a portaudio-2.0.pc file for pkg-config. Mine (on macOS) exists at /usr/local/lib/pkgconfig/portaudio-2.0.pc. I suppose /usr/local/lib/pkgconfig/ is the default path and doesn't need to be added to PKG_CONFIG_PATH. It looks like this file is generated (from this) when you build PortAudio; otherwise you'll need to write it yourself.

You can run pkg-config portaudio-2.0 --libs --cflags to check whether the .pc file is found.

When looking at the file mentioned here I find that line 16 is contained in a multi line comment, so the fact that it is complaining makes no sense to me.

This is how cgo works: A magic comment preceding the import of pseudo-package C.

@dh1tw
Copy link

dh1tw commented Oct 1, 2021

Hi Aidan,

Msys2 provides MinGW + Pacman, the Arch Package Manager. Through Pacman you can install most libraries, incl. portAudio.

Another option for running gcc on Windows is tdm-gcc. I also made good experience with tdm-gcc compiling cgo projects natively on Windows hosts.

For cross-compiling, feel free to fork and adjust remoteAudio-xcompile to your needs.

@Raraku
Copy link

Raraku commented Dec 14, 2021

I am having the exact same issue. I've added the location to the PKG_CONFIG_PATH but there's no difference

@gordonklaus
Copy link
Owner

I believe this issue was solved by @dh1tw's suggestion. If not, please re-open.

@gordonklaus
Copy link
Owner

I eventually tried to do this myself and ran into the same problem as @Raraku.

Getting this error:

$ go build .
# pkg-config --cflags  -- portaudio-2.0
Package portaudio-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `portaudio-2.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'portaudio-2.0', required by 'virtual:world', not found
pkg-config: exit status 1

in spite of this working as expected:

$ pkg-config --cflags  -- portaudio-2.0
-IC:/msys64/mingw64/include

I was able to solve the problem by installing mingw-w64-x86_64-pkg-config:

pacman -S mingw-w64-x86_64-pkg-config

I have no idea why the pre-installed pkg-config did not work as expected.

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

No branches or pull requests

4 participants