Skip to content

Conversation

@MengLinMaker
Copy link

Merging correct branch, initially #10.

Successfully building libsndfile for issue #9

The CMakeLists.txt is currently written to succeed despite not finding packages.
Ideally it should fail when a package is not found.
Why build for something if it lacks the feature we want?

VCPKG provides ".pc" files required by pkg_check_modules()

I've added CMakePresets.json to simplify build scripts in makefile.

Effect of changes:

  • Require VCPKG dependency installation to build consistency between computers.
  • Disable most features by default - except BUILD_SHARED_LIBS for wasm build.
  • Do not build if dependencies cannot be found - for consistent build.

jet2jet and others added 10 commits December 27, 2022 22:55
…problems trying to load the module. There are also some changes here that I had previously made for 2.2.1.

    With these changes I am able to build and load fluidsynth as an AudioWorklet processor.

    From v2.2.1 also needed in v2.3.0
    - Added some additional EXPORTS to CMakelists.txt to fix runtime unresolveds: addFunction,removeFunction,MEMFS,lengthBytesUTF8,UTF8ArrayToString,UTF8ToString,stringToUTF8Array,stringToUTF8.

    Additional change for 2.3.0
    Failed to Base64 decode the WASM binary b/c atob() didn't exist.  Maybe it's not defined in the AudioWorklet scope?  I put back a polyfill that was in the 2.2.1 code, added this to pre.js.

    Build tools:
    emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.43 (a6b8143cf3c1171db911750359456b15a8deece7)
    clang version 17.0.0 (https://github.com/llvm/llvm-project 71513a71cdf380efd6a44be6939e2cb979a62407)
    Target: wasm32-unknown-emscripten
    Thread model: posix

    Tested on Chrome Version 114.0.5735.133 (Official Build) (64-bit)

    Significant possibility that this is user error on my part, but I was not able to find another solution.
Changes to load fluidsynth-emscriptem as an AudioWorklet processor
@jet2jet
Copy link
Owner

jet2jet commented Oct 8, 2024

Thanks for the PR. I successfully built libfluidsynth.js with libsndfile.
In my environment, it is necessary to run commands like this:

mkdir build-with-sndfile # or any directory name
cd build-with-sndfile
# These two lines seem to be necessary for vcpkg to detect compilers correctly
export CC=emcc
export CXX=em++
cmake -DCMAKE_TOOLCHAIN_FILE=<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=<path-to-emscripten>/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -Denable-aufile=off -Denable-oss=off -Denable-libsndfile=on -DCMAKE_BUILD_TYPE=Release ..

If you can, please write building instruction (with vcpkg) to README.md.

*.user

# Package manager
vcpkg_installed
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be unnecessary because vcpkg_installed is created in build directory by default.
(Executing build command on the root directory is not recommended.)

Copy link
Author

@MengLinMaker MengLinMaker Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My makefile is gitignored, whoops.
Why is executing build on root not recommended?
The build output will still be generated in the "build" folder.

For me I run - on macos:

1. Install dependency - in this case sndfile according to vcpkg.json

vcpkg install --triplet wasm32-emscripten

This creates a vcpkg_installed folder in project root.

2. Build file

emcmake cmake -B build/wasm-libsndfile --preset wasm-libsndfile
emmake make -C build/wasm-libsndfile

Here is a the makefile I used that is gitignored:

install:
	vcpkg install --triplet wasm32-emscripten

wasm:
	emcmake cmake -B build/wasm-vanilla --preset wasm
	emmake make -C build/wasm-vanilla

wasm-libsndfile:
	emcmake cmake -B build/wasm-libsndfile --preset wasm-libsndfile
	emmake make -C build/wasm-libsndfile

clean:
	rm -rf build

Preset options are written in CMakePresets.json

Then we can extend presets and add installation scripts to makefile for different configs.

Build instructions

make install
make wasm-libsndfile

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response.
The build directory is a recommendation based on the original FluidSynth building instruction (https://github.com/FluidSynth/fluidsynth/wiki/BuildingWithCMake).
I think it has an advantage that the all intermediate/output files will be generated into build directory.

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

Successfully merging this pull request may close these issues.

3 participants