tags:

views:

447

answers:

2

Hi all,

I'm trying to build a Win32 DLL from an audio-DSP related Linux library (http://breakfastquay.com/rubberband/). There are makefiles and config scripts for Linux, but no help for Windows. The author provides a Win32 binary of a sample app using the library, and I see a number of "#ifdef MSVC" and "#ifdef WIN32" scattered around, so I don't think I'm starting completely from scratch but I'm stuck nevertheless.

As my programming knowledge in either platform is rather limited, I'd appreciate any help.

First of all, what is the right way to get started here? Visual Studio? Cygwin? Initially I started off creating a Win32 DLL project in Visual Studio, adding the source files, thinking about adding a .def file, etc, but at some point I felt like this was going nowhere.

As for Cygwin, this was the first time using it, and I don't even know if this is the sort of thing that Cygwin is designed for. Is it?

On Cygwin, I ran ./configure and got stuck at something like this:

"checking for SRC... configure: error: Package requirements (samplerate) were not met: No package 'samplerate' found"

After looking through the log, it appears that pkg-config is looking for samplerate.pc. How do I handle packages in Windows? libsamplerate is just an open source library, and I have source and a DLL for this. But I'm not sure how to use them to satisfy the dependency requirements for librubberband (which is what I'm trying to build)

I'm completely lost at this point and if anyone can give me a nudge in the right direction... and, is there an easier way to do this?

Many thanks in advance.

+1  A: 

Linux to w32 is mostly a tricky thing.
For each of your dependencies, download the source and:

./configure
make
sudo make install

Also, I recommend you to use MinGW + msys in place of CygWin (as the latter produces executables that depend on its libraries). However in your situtation, use the VS approach -- 't will save you a lot of time.

Aviral Dasgupta
A: 

If you're still stuck on this I can throw a little light.

You may have to build everything from sources (or have the libraries installed in your environment). You're using Cygwin, I would recommend MinGW and MSYS too, but sometimes it's just not possible to use this combination to build the program or library.

So if using Cygwin, first ensure that you have a proper environment installed. This is that you have the correct development headers installed.

Then download libsndfile. Extract the sources to a directory and from the Cygwin bash shell navigate to that directory. There perform:

./configure
make
make install prefix=/cygdrive/c/cygwin

Notice that I use a prefix, that prefix should point to the directory Cygwin is installed in order to correctly install the libraries (the same happens to MinGW and MSYS, the prefix should point to the MinGW installation directory). Maybe using the usr directory in the prefix works too, I've never tried it.

Now download FFTW, as it will be needed for libsamplerate and rubberband. Same procedure as with libsndfile: extract, configure, make & make install using the prefix. Now copy the header files of FFTW (in the example they'd be in /cygdrive/c/cygwin/include) to the include directory in the usr directory (in the example /cygdrive/c/cygwin/usr/include).

Next SRC (libsamplerate), same procedure.

Then the Vamp plugin SDK. In order to compile the it you may need to edit the file src\vamp-hostsdk\PluginLoader.cpp, deleting RTLD_LOCAL from a dlopen() call (it's safe, it's already the default behaviour).

Also, you may need to install it by hand (in my experiences it didn't like the prefix). Or set the environmental variable PKG_CONFIG_PATH pointing to the paths of pkgconfig, e.g.:

set PKG_CONFIG_PATH=/cygdrive/c/cygwin/lib/pkgconfig:/usr/local/lib/pkgconfig

Now, create a file called ladspa.h in the include directory with the contents of the LADSPA header

Finally, configure and build rubberband, it should find everything it needs.

To build in MSYS using MinGW follow the same procedure, using the according prefix. Using Visual Studio is another alternative, but you may need to use some of the pre-built libraries (for example for libsndfile) as building Linux libraries natively in Windows may be complicated or even impossible (without hacking the source code) in VS.

Anyway, the autor of rubberband provides binaries; I think you should consider use them instead of going through all of this.

Xandy
Thanks for this detailed response. As a matter of fact, I am still stuck. I did eventually get it to compile in VS, but linking against it is not working. I may have to take another huge detour and get it to work in MinGW or Cygwin... I couldn't use the author-provided binaries in the first place since that's just a simple sample app using the binary, not a binary to the library itself (correct me if I'm wrong); otherwise I would have been more than happy to forego all this trouble.In any case, thanks for your answer. I'll have to give this a try.
psas
I don't know if you'll end up seeing this, but I think I have just one remaining hurdle before I get this working. I'm on MinGW/MSYS and have linbsndfile, libsamplerate, fftw3 and vamp sorted out. But librubberband also seems to require the pthreads library. What's the solution here? Install pthreads-win32? Are there any noob-friendly guides to installing pthreads-win32, because I had trouble finding one.It sounds like you've done this before so maybe you have some insight into this. Again, thanks!
psas
Hmm... Yes, I've done it in a Cygwin environment (where you were working in the beginning) so pthreads was already available. For MinGW you have 2 choices, either compile pthreads-win32 by yourself (you may get the package here: sourceforge.net/projects/mingw/files look in the GCC4 current release files) or use a already compiled lib. You may find it too in the same place as the sources or here sourceforge.net/projects/mingw-w64/files under "external binary packages". Let me know anything else :)
Xandy
I actually opted not to use pthreads at all (the reasoning being, the README file indicates that pthreads are not necessary on Win32) and try my luck with hacking. I think it turned out well actually. Just had to add '#define _Win32' to Thread.h and remove the -lpthread in the Makefile LDFLAGS and it compiled/linked fine. It built the /bin/rubberband.exe which works. I have yet to use the .dll in my app yet, but hey, I'm patting myself on the back for getting this far (ignorance leads to low expectations...)! Thanks again for your help in this; I don't think I would have gotten here googling.
psas
You're welcome! I'm glad it worked!
Xandy