Closed moondayyy closed 10 months ago
You've included the implementation in both main.cpp and audio.cpp because your .h file has #define MINIAUDIO_IMPLEMENTATION
in it before #include miniaudio.h
. The implementation can only be included once. Either remove MINIAUDIO_IMPLEMENTATION
to one .cpp file, or use the split version in the extras folder like a traditional .h/.c pair.
Thank you for your answer, as you said, I used the .c and .h files in the miniaudio/extras/miniaudio_split folder, but this time I encounter the following error:
wasm-ld: error: --shared-memory is disallowed by CMakeFiles/Wasm_Thread_Testt.dir/Audio/miniaudio.c.o because it was not compiled with 'atomics' or 'bulk-memory' features.
NOTE: I get this error when I add CMakeLists.txt -sUSE_PTHREADS, I need this flag to add a worker to my project.
CMakeLists.txt:
cmake_minimum_required(VERSION 3.22)
project(Wasm_Thread_Testt)
set(CMAKE_CXX_STANDARD 23)
add_executable(Wasm_Thread_Testt main.cpp Audio/audio.cpp Audio/miniaudio.c)
set_target_properties(Wasm_Thread_Testt PROPERTIES LINK_FLAGS "-s USE_PTHREADS -sPTHREAD_POOL_SIZE=20 -s EXPORT_ALL=1")
I added miniaudio to my Audio layer and when I call the audio.h header file from main.cpp, I get a "duplicate symbol" error. (Emscripten Clang17)
Audio/audio.h:
Audio/audio.cpp:
main.cpp:
CMakeLists.txt:
Error Message: