DISTRHO / Cardinal

Virtual modular synthesizer plugin
https://cardinal.kx.studio/
GNU General Public License v3.0
2.28k stars 155 forks source link

Can't get Windows cross-building working in Ubuntu. Missing documentation? #458

Closed zjacreman closed 1 year ago

zjacreman commented 1 year ago

Hello!

I'm trying to cross-build for 64-bit Windows from a fresh Ubuntu 22.04 VM. My hope was to be able to assist with adding modules to Cardinal, and Windows is where my audio hardware is set up and I can test things.

I've gotten the Linux build going with minimal issues but I just can't get Windows cross-building to work.

I tried the native msys2 route first as suggested in the build documentation but then hit issue #446 and changed strategies, as apparently that isn't actually supported?

I'm still hitting undocumented problems. I've had to build libsndfile and liblo from source, with configuration to target them at x86_64-w64-mingw32; installing the Ubuntu package for a library seems to make it accessible to mingw sometimes but not all the time.

Then I got stuck here:

make[1]: Entering directory '/home/zjacreman/repos/Cardinal/src'
make -C Cardinal
make[2]: Entering directory '/home/zjacreman/repos/Cardinal/src/Cardinal'
Compiling distrho.rc
make[2]: ../../utils/distrho.rc: Permission denied
make[2]: *** [../Makefile.cardinal.mk:472: ../../build/Cardinal/distrho.rc.o] Error 127
make[2]: Leaving directory '/home/zjacreman/repos/Cardinal/src/Cardinal'
make[1]: *** [Makefile:217: all] Error 2
make[1]: Leaving directory '/home/zjacreman/repos/Cardinal/src'
make: *** [Makefile:159: cardinal] Error 2

There isn't any permission-related issue that I can see:

zjacreman@ubuntu-devbox:~/repos/Cardinal/utils$ ls -lah
total 284K
...
-rw-rw-r--  1 zjacreman zjacreman   45 dic 11 19:45 distrho.rc
...

OK, I don't actually need an installer so I'll comment those parts out of Makefile.cardinal.mk.

And I get a little further:

make all -C src CARLA_BACKEND_NAMESPACE=Cardinal DGL_NAMESPACE=CardinalDGL HAVE_FFMPEG=false HAVE_FLUIDSYNTH=false HAVE_PROJECTM=false HAVE_ZYN_DEPS=false HAVE_ZYN_UI_DEPS=false EXTERNAL_PLUGINS=true
make[1]: Entering directory '/home/zjacreman/repos/Cardinal/src'
make -C Cardinal
make[2]: Entering directory '/home/zjacreman/repos/Cardinal/src/Cardinal'
Creating LV2 plugin for Cardinal
/usr/bin/x86_64-w64-mingw32-ld: cannot find -llo: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lFLAC: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lvorbisenc: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lvorbis: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -logg: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lopus: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lFLAC: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lvorbisenc: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lvorbis: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -logg: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lopus: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -llo: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [../../dpf/Makefile.plugins.mk:504: ../../bin/Cardinal.lv2/Cardinal.dll] Error 1
make[2]: Leaving directory '/home/zjacreman/repos/Cardinal/src/Cardinal'
make[1]: *** [Makefile:217: all] Error 2
make[1]: Leaving directory '/home/zjacreman/repos/Cardinal/src'
make: *** [Makefile:159: cardinal] Error 2

I've definitely built liblo with a .dll.a file; /usr/bin/x86_64-w64-mingw32-ld -llo doesn't throw an error outside of the make context. So finding the source and building the ogg and flac etc. libraries isn't going to get me anywhere just now.

What am I missing? Is there something I should be passing to make, some modification I need to make somewhere? How is it set up on the system you're using to build releases?

Cheers

dromer commented 1 year ago

Read the GH-Actions file? -> https://github.com/DISTRHO/Cardinal/blob/main/.github/workflows/build.yml#L996

falkTX commented 1 year ago

the actions file is a bit complex as it sets up dependencies through pawpaw, not needed for simple dev builds. the section on https://github.com/DISTRHO/Cardinal/blob/main/docs/BUILDING.md#cross-compile should be enough, what might be missing is WINDRESvariable being set, that is what is used to convert res/ico files

for the libs missing, what might be happening is pkg-config being used from the linux system instead of negating libs presence.

so it is likely missing entries on documentation yes, this should improve things a bit:

# build tools
export AR=x86_64-w64-mingw32-ar
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++
export WINDRES=x86_64-w64-mingw32-windres
# run generated executables through wine, needed for lv2 ttl generation
export EXE_WRAPPER=wine
# ignore pkg-config entirely
export PKG_CONFIG=false

note that changing PKG_CONFIG requires a rebuild.

let me know if that works for you

falkTX commented 1 year ago

Did a build myself locally, and indeed instructions were outdated. They have been corrected in https://github.com/DISTRHO/Cardinal/commit/3eddf06b41e616d0a7316e4045ade7dba8850e50