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

Get build.rs script for Windows working #71

Open
killkrt opened this issue Apr 15, 2015 · 10 comments
Open

Get build.rs script for Windows working #71

killkrt opened this issue Apr 15, 2015 · 10 comments
Labels

Comments

@killkrt
Copy link

killkrt commented Apr 15, 2015

Hi,

I'm trying to compiling rust-portaudio under Windows 7 SP1 64bit with Rust 1.0.0 (9854143cb 2015-04-02), but I'm getting the following error:

   Compiling portaudio v0.4.0 (file:https:///C:/temp/rust/rust-portaudio)
     Running `rustc build.rs --crate-name build_script_build --crate-type bin -C
 prefer-dynamic -g --out-dir C:\temp\rust\rust-portaudio\target\debug\build\port
audio-abac5c6e3fd19304 --emit=dep-info,link -L dependency=C:\temp\rust\rust-port
audio\target\debug -L dependency=C:\temp\rust\rust-portaudio\target\debug\deps -
-extern pkg_config=C:\temp\rust\rust-portaudio\target\debug\deps\libpkg_config-c
0e9294bfeefddd9.rlib`
       Fresh pkg-config v0.3.3
       Fresh libc v0.1.6
       Fresh rustc-serialize v0.3.12
   Compiling num v0.1.22
     Running `rustc C:\Users\KillKRT\.cargo\registry\src\github.com-1ecc6299db9e
c823\num-0.1.22\src\lib.rs --crate-name num --crate-type lib -g -C metadata=798f
e7e31b30dacd -C extra-filename=-798fe7e31b30dacd --out-dir C:\temp\rust\rust-por
taudio\target\debug\deps --emit=dep-info,link -L dependency=C:\temp\rust\rust-po
rtaudio\target\debug\deps -L dependency=C:\temp\rust\rust-portaudio\target\debug
\deps --extern rand=C:\temp\rust\rust-portaudio\target\debug\deps\librand-7b0a3a
f7ae4685dc.rlib --extern rustc_serialize=C:\temp\rust\rust-portaudio\target\debu
g\deps\librustc_serialize-70d93d5334da1e4e.rlib -Awarnings`
       Fresh log v0.3.1
       Fresh rand v0.3.7
build.rs:48:9: 48:29 error: this function takes 1 parameter but 0 parameters wer
e supplied [E0061]
build.rs:48         platform::download();
                    ^~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
Could not compile `portaudio`.

Caused by:
  Process didn't exit successfully: `rustc build.rs --crate-name build_script_bu
ild --crate-type bin -C prefer-dynamic -g --out-dir C:\temp\rust\rust-portaudio\
target\debug\build\portaudio-abac5c6e3fd19304 --emit=dep-info,link -L dependency
=C:\temp\rust\rust-portaudio\target\debug -L dependency=C:\temp\rust\rust-portau
dio\target\debug\deps --extern pkg_config=C:\temp\rust\rust-portaudio\target\deb
ug\deps\libpkg_config-c0e9294bfeefddd9.rlib` (exit code: 101)

I've also tried to compile under a MinGW64 environment, but I got the same error.

@mitchmindtree
Copy link
Member

@killkrt Thanks for posting the issue! It seems the reason you're running into this error is because no one has yet had a chance to make the build script work with windows (most of us are on macos / linux) - see here for the relevant part that's failing to compile. All the build script does is:

  • Check for an existing installation of portaudio.
  • If it does exist, we are done (this part is already implemented - see here).
  • If it doesn't exist, download and install it, then we are done (this is the unimplemented part).
    You'll notice that, even once you can get it to compile (by removing the unused _: &Path argument) it will panic straight away if portaudio isn't installed as the windows platform module is unimplemented.

This shouldn't be too tricky to implement at all, if you're up for having a go at it, it'd be well appreciated! (I would have done it by now if I had a windows machine to test on). You can see how the unix platforms do the job in the same module - you basically want to aim to do the same thing but for windows. The instructions for downloading and installing PortAudio can be found here.

@killkrt
Copy link
Author

killkrt commented Apr 18, 2015

I will try, but consider that I am a beginner in Rust and I don't like developing on Windows, anyway I have to since I'd like to develop a cross-platform DAW.

@filmor
Copy link
Contributor

filmor commented Nov 3, 2015

This particular error is just because the download function adds an erronous parameter which is fixed by #106. It would also be enough to raise a warning here, because you only need to place a pulseaudio_x64.dll (or the 32bit variant if needed) at the root of your own project and inside of the target/{debug,release}/deps folder (under the name libportaudio.dll if I recall correctly). Not nice, but works fine.

@yupferris
Copy link

This is still the case, many months later :) the script still has the extra parameter for the download function.

As for actually building, it's probably at least safe to use gcc. I haven't looked into the process of actually building it on Windows, though. Will have to check that out.

@yupferris
Copy link

After giving it a quick go, the first two issues are this:

  • The latest source is distributed as a tgz, which Windows doesn't have out-of-the-box support for afaik.
  • PortAudio's configure script doesn't appear to work under msys2. I haven't tried with anything else.

@mitchmindtree mitchmindtree changed the title Build fails under Windows 7 SP1 Get build.rs script for Windows working Mar 8, 2016
@kryptan
Copy link
Contributor

kryptan commented Apr 11, 2016

The latest source is distributed as a tgz, which Windows doesn't have out-of-the-box support for afaik.

There are flate2 and tar crates.

@lschmierer
Copy link

Isn't it possible to include PortAudio as submodule (here is the Git repo) and build it directly in the build script using https://github.com/alexcrichton/gcc-rs ?

@killkrt
Copy link
Author

killkrt commented Aug 19, 2016

I have made some tests on Windows 10 and I found that a possible (maybe a little tricky solution) could be implemented.

Here you can find a pre-compiled version of Portaudio for Windows.

The archive contains lot of stuff, in particularly there are the LIB and DLL file needed.

For example: for the 64 bit version those files can be found in portaudio-r1891-build.zip\portaudio-r1891-build\lib\x64\Release\. Both of them (portaudio_x64.lib and portaudio_x64.dll) shall be copied in the root folder of the rust-portaudio project, and the LIB file has to be renamed with portaudio.lib.

So an idea could be that the build script asks the user if it has to proceed automatically, then it downloads the ZIP file, extracts it in a temp folder and copies the right stuff in the right place.

Do you think it's to tricky or it could be a solution?

@ottworks
Copy link

Fix this. It's been 16 months.

@cr1901
Copy link

cr1901 commented Apr 20, 2019

I have pkg-config installed on my Windows machine, but I decided to take a look at build.rs out of curiosity about how rust-portaudio handles a lack of pkg-config on Windows. I will test later this weekend, hopefully.

You only need to place a pulseaudio_x64.dll (or the 32bit variant if needed) at the root of your own project and inside of the target/{debug,release}/deps folder (under the name libportaudio.dll if I recall correctly).

I think this is a decent, low-impact workaround for Windows users without pkg-config. Perhaps it can be improved adding an (Windows-only?) env variable that specifies a path where to look for a portaudio as well, and fallback to target/{debug,release}/deps (since that will be cleaned up by cargo clean).

Right now, the filename that build.rs appears to be hardcoded to libportaudio.a. This could be changed to libportaudio.dll with a cfg platform branch.

However, from what I can tell without running it, building rust-portaudio-sys without pkg-config installed is completely broken on Windows, even if libportaudio.a is supplied in the correct directory. If there is a match[https://github.com/RustAudio/rust-portaudio/blob/master/rust-portaudio-sys/build.rs#L52] for the library in Cargo's OUT_DIR, print_libs is unconditionally called, which panics on Windows. Perhaps print_libs on Windows should manually print out the cargo strings that pkg-config-rs normally would.

Thoughts/comments/objections welcome :)!

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

No branches or pull requests

8 participants