Cross compile DPF for Windows

Programming applications for making music on Linux.

Moderators: khz, MattKingUSA

User avatar
Michael Willis
Establlshed Member
Posts: 488
Joined: Mon Oct 03, 2016 3:27 pm

Cross compile DPF for Windows

Postby Michael Willis » Tue Apr 10, 2018 2:30 pm

Hey FalkTX (or anybody else), can I cross compile a DPF project to make a Windows VST from Linux? After a cursory investigation I learned that mingw can be used to compile Windows binaries, so I installed it and trying running

Code: Select all

make WIN32=true
on my project, but the build promptly failed with this cryptic message:

Code: Select all

/usr/bin/ld: /tmp/ccknSAGM.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/tmp/ccknSAGM.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
../Makefile.mk:135: recipe for target '../../bin/DragonflyReverb.lv2/DragonflyReverb_dsp.dll' failed


I was thinking about hacking around with the Makefiles to introduce the -fPIC parameter, but then decided I should probably ask after your last commentary about my hacks on the Makefiles :oops:

User avatar
lucianodato
Establlshed Member
Posts: 145
Joined: Sat May 15, 2010 9:00 pm

Re: Cross compile DPF for Windows

Postby lucianodato » Tue Apr 10, 2018 2:58 pm

Damien from zamaudio did something like that using travisci look at his repo.
Arguy (IRC)

User avatar
falkTX
Establlshed Member
Posts: 6645
Joined: Sat Jan 09, 2010 3:04 pm

Re: Cross compile DPF for Windows

Postby falkTX » Tue Apr 10, 2018 3:10 pm

I bet you do not have the needed mingw setup on the environment, because -fPIC is not needed for windows builds.
It's in my plans to update the makefiles a little, remove the need for "WIN32=true" and check if the target is possible to build in the first place.

note that you also need wine for the full build, as we need to run a tool post-build to generate ttl files.

User avatar
Michael Willis
Establlshed Member
Posts: 488
Joined: Mon Oct 03, 2016 3:27 pm

Re: Cross compile DPF for Windows

Postby Michael Willis » Tue Apr 10, 2018 3:45 pm

lucianodato wrote:Damien from zamaudio did something like that using travisci look at his repo.

Oh nice, this is looking promising: Cross compiling: Add build scripts for OSX/WIN/GNU using docker

falkTX wrote:I bet you do not have the needed mingw setup on the environment, because -fPIC is not needed for windows builds.

Thanks, all I tried was installing the debian package mingw-w64 and running the make. I'll learn a bit more about mingw and get wine set up, then try again.

User avatar
Michael Willis
Establlshed Member
Posts: 488
Joined: Mon Oct 03, 2016 3:27 pm

Re: Cross compile DPF for Windows

Postby Michael Willis » Wed Apr 11, 2018 3:15 am

falkTX wrote:... mingw ... wine ...

Ok, I got a little bit further. I found that I can run the following command and it uses the mingw compiler instead of gcc/g++:

Code: Select all

make WIN32=true CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++

It looks like it compiles all of my source files, but then when it gets to the linking phase it doesn't know how to find fftw3:

Code: Select all

/usr/bin/x86_64-w64-mingw32-ld: cannot find -lfftw3f
collect2: error: ld returned 1 exit status
../Makefile.mk:135: recipe for target '../../bin/DragonflyReverb.lv2/DragonflyReverb_dsp.dll' failed

This is understandable, but I don't know where to put the fftw3 library. Ideally I want to statically link fftw3, but it's not clear to me how to properly set up my Makefiles to do so.

Furthermore, just to see if I could get *any* DPF project to cross compile, I tried building the Distrho Mverb project, and it gave me this when it tried to create the lv2:

Code: Select all

err:module:import_dll Library libgcc_s_seh-1.dll (which is needed by L"Z:\\home\\michael\\workspace\\MVerb\\bin\\MVerb.lv2\\MVerb_dsp.dll") not found
err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\michael\\workspace\\MVerb\\bin\\MVerb.lv2\\MVerb_dsp.dll") not found
Failed to open plugin DLL
Makefile:26: recipe for target 'gen' failed

It does look like it built the Windows VST for that project, but I'm not sure if the VST has any dependencies dynamically linked.

User avatar
falkTX
Establlshed Member
Posts: 6645
Joined: Sat Jan 09, 2010 3:04 pm

Re: Cross compile DPF for Windows

Postby falkTX » Wed Apr 11, 2018 8:11 am

Ok, so..
First, you need to build fftw with mingw if you want to have your plugin use it.
You can't mix linux and windows libraries ;)

For the error you get with mverb, you likely need -static and -static-libc++ (or something like that), to make sure the final binary does not depend on any external dlls and works correctly by itself.

User avatar
Michael Willis
Establlshed Member
Posts: 488
Joined: Mon Oct 03, 2016 3:27 pm

Re: Cross compile DPF for Windows

Postby Michael Willis » Fri Apr 13, 2018 12:41 am

falkTX wrote:Ok, so..

Thanks falkTX. I got the make command to succeed, and a dll file showed up in the bin dir. One windows user tested it and told me this:

Samulis wrote:I tried it in Reaper and Finale, but it wouldn't even get recognized by the plugin scanners. I don't know if there's a log somewhere for those, but no errors came up.

I'm not really sure what to do from here. For what it's worth, here's the file: https://github.com/michaelwillis/dragon ... v0.9.0.zip

User avatar
falkTX
Establlshed Member
Posts: 6645
Joined: Sat Jan 09, 2010 3:04 pm

Re: Cross compile DPF for Windows

Postby falkTX » Fri Apr 13, 2018 7:09 am

The error for this is simple. When loaded into carla, I get:

Code: Select all

err:module:import_dll Library libfftw3f-3.dll (which is needed by L"Z:\\home\\falktx\\DragonflyReverb-vst.dll") not found


You need to build fftw statically.
Careful if you use the fftw planner, needs some tricks to make sure concurrent use does not crash.

User avatar
Michael Willis
Establlshed Member
Posts: 488
Joined: Mon Oct 03, 2016 3:27 pm

Re: Cross compile DPF for Windows

Postby Michael Willis » Fri Apr 13, 2018 10:56 am

falkTX wrote:When loaded into carla

Oh right, I didn't even think of using the Carla bridge to test it! I thought I just had to blindly send the dll to somebody with windows.

falkTX wrote:Careful if you use the fftw planner, needs some tricks to make sure concurrent use does not crash.

I changed my spectrogram implementation such that it doesn't use a separate thread to render (per the suggestion of the ardour devs). Now It renders in chunks during the uiIdle event.

User avatar
falkTX
Establlshed Member
Posts: 6645
Joined: Sat Jan 09, 2010 3:04 pm

Re: Cross compile DPF for Windows

Postby falkTX » Fri Apr 13, 2018 11:36 am

Michael Willis wrote:
falkTX wrote:Careful if you use the fftw planner, needs some tricks to make sure concurrent use does not crash.

I changed my spectrogram implementation such that it doesn't use a separate thread to render (per the suggestion of the ardour devs). Now It renders in chunks during the uiIdle event.

That is not relevant actually. The issue is a host running 2 instances of the plugin in parallel, and fftw having global state will trigger race conditions and eventually crash.
Not all hosts run UI stuff in parallel, but I know at least ableton does-


Return to “Developer's Section”

Who is online

Users browsing this forum: No registered users and 12 guests