ZDoom / ZMusic

GZDoom's music system as a standalone library
https://forum.zdoom.org/index.php
60 stars 32 forks source link

Build unconditionally fails when compiling non-native #54

Closed madame-rachelle closed 6 months ago

madame-rachelle commented 6 months ago

I don't know if this is an issue with the included libraries in ZMusic, or if there's something wrong with ZMusic itself, but if you build for an alternate architecture (i.e. x86_64 on Mac OS while using an M1 Mac, or to ARM64 on Windows while using an x64) - it will always compile at least one of the link objects to the native architecture which it is not supposed to and should not do. This causes the linking of the final binary to always fail.

alexey-lysiuk commented 6 months ago

Clean build of ARM64 Debug and Release configuration succeeded with VS2022 running x64 Windows 10.

madame-rachelle commented 6 months ago

Odd, I guess Windows was working.

This is an error I am getting on Mac OS when I compile to x86_64:


[ 15%] Built target gme
[ 41%] Built target dumb
[ 45%] Built target adl
[ 54%] Built target opn
[ 57%] Built target timidity
[ 63%] Built target timidityplus
[ 65%] Built target wildmidi
[ 67%] Built target oplsynth
[ 79%] Built target fluidsynth
[ 79%] Linking CXX shared library libzmusic.dylib
ld: warning: ignoring file /opt/local/lib/libglib-2.0.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
  "_g_clear_error", referenced from:
      _new_fluid_thread in fluid_sys.c.o
  "_g_cond_broadcast", referenced from:
      _delete_rvoice_mixer_threads in fluid_rvoice_mixer.c.o
      _fluid_render_loop_multithread in fluid_rvoice_mixer.c.o
  "_g_cond_clear", referenced from:
      _delete_fluid_rvoice_mixer in fluid_rvoice_mixer.c.o
  "_g_cond_init", referenced from:
      _new_fluid_rvoice_mixer in fluid_rvoice_mixer.c.o
  "_g_cond_signal", referenced from:
      _fluid_mixer_thread_func in fluid_rvoice_mixer.c.o
  "_g_cond_wait", referenced from:
      _fluid_render_loop_multithread in fluid_rvoice_mixer.c.o
      _fluid_mixer_thread_func in fluid_rvoice_mixer.c.o
  "_g_file_test", referenced from:
      _fluid_file_open in fluid_sys.c.o
  "_g_free", referenced from:
      _delete_fluid_rvoice_mixer in fluid_rvoice_mixer.c.o
  "_g_get_monotonic_time", referenced from:
      _fluid_curtime in fluid_sys.c.o
      _fluid_utime in fluid_sys.c.o
      _fluid_timer_run in fluid_sys.c.o
  "_g_malloc", referenced from:
      _new_fluid_rvoice_mixer in fluid_rvoice_mixer.c.o
  "_g_mutex_clear", referenced from:
      _delete_fluid_rvoice_mixer in fluid_rvoice_mixer.c.o
      _delete_fluid_midi_router in fluid_midi_router.c.o
  "_g_mutex_init", referenced from:
      _new_fluid_rvoice_mixer in fluid_rvoice_mixer.c.o
      _new_fluid_midi_router in fluid_midi_router.c.o
  "_g_mutex_lock", referenced from:
      _fluid_samplecache_load in fluid_samplecache.c.o
      _fluid_samplecache_unload in fluid_samplecache.c.o
      _fluid_samplecache_count_entries in fluid_samplecache.c.o
      _delete_rvoice_mixer_threads in fluid_rvoice_mixer.c.o
      _fluid_render_loop_multithread in fluid_rvoice_mixer.c.o
      _fluid_mixer_thread_func in fluid_rvoice_mixer.c.o
      _fluid_midi_router_set_default_rules in fluid_midi_router.c.o
      ...
  "_g_mutex_unlock", referenced from:
      _fluid_samplecache_load in fluid_samplecache.c.o
      _fluid_samplecache_unload in fluid_samplecache.c.o
      _fluid_samplecache_count_entries in fluid_samplecache.c.o
      _delete_rvoice_mixer_threads in fluid_rvoice_mixer.c.o
      _fluid_render_loop_multithread in fluid_rvoice_mixer.c.o
      _fluid_mixer_thread_func in fluid_rvoice_mixer.c.o
      _fluid_midi_router_set_default_rules in fluid_midi_router.c.o
      ...
  "_g_private_get", referenced from:
      _fluid_synth_tuning_iteration_next in fluid_synth.c.o
  "_g_private_set", referenced from:
      _fluid_synth_tuning_iteration_start in fluid_synth.c.o
      _fluid_synth_tuning_iteration_next in fluid_synth.c.o
  "_g_rec_mutex_clear", referenced from:
      _delete_fluid_settings in fluid_settings.c.o
      _fluid_sffile_close in fluid_sffile.c.o
      _delete_fluid_synth in fluid_synth.c.o
      _new_fluid_sequencer2 in fluid_seq.c.o
      _delete_fluid_sequencer in fluid_seq.c.o
  "_g_rec_mutex_init", referenced from:
      _new_fluid_settings in fluid_settings.c.o
      _fluid_sffile_open in fluid_sffile.c.o
      _new_fluid_synth in fluid_synth.c.o
      _new_fluid_sequencer2 in fluid_seq.c.o
  "_g_rec_mutex_lock", referenced from:
      _fluid_settings_register_str in fluid_settings.c.o
      _fluid_settings_register_num in fluid_settings.c.o
      _fluid_settings_register_int in fluid_settings.c.o
      _fluid_settings_callback_str in fluid_settings.c.o
      _fluid_settings_callback_num in fluid_settings.c.o
      _fluid_settings_callback_int in fluid_settings.c.o
      _fluid_settings_get_user_data in fluid_settings.c.o
      ...
  "_g_rec_mutex_unlock", referenced from:
      _fluid_settings_register_str in fluid_settings.c.o
      _fluid_settings_register_num in fluid_settings.c.o
      _fluid_settings_register_int in fluid_settings.c.o
      _fluid_settings_callback_str in fluid_settings.c.o
      _fluid_settings_callback_num in fluid_settings.c.o
      _fluid_settings_callback_int in fluid_settings.c.o
      _fluid_settings_get_user_data in fluid_settings.c.o
      ...
  "_g_return_if_fail_warning", referenced from:
      _new_fluid_thread in fluid_sys.c.o
  "_g_thread_join", referenced from:
      _fluid_thread_join in fluid_sys.c.o
      _delete_fluid_timer in fluid_sys.c.o
      _fluid_timer_join in fluid_sys.c.o
  "_g_thread_try_new", referenced from:
      _new_fluid_thread in fluid_sys.c.o
  "_g_thread_unref", referenced from:
      _new_fluid_thread in fluid_sys.c.o
  "_g_usleep", referenced from:
      _fluid_msleep in fluid_sys.c.o
      _fluid_timer_run in fluid_sys.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [source/libzmusic.1.1.12.dylib] Error 1
make[1]: *** [source/CMakeFiles/zmusic.dir/all] Error 2
make: *** [all] Error 2```
alexey-lysiuk commented 6 months ago

You need to figure out what software is installing libraries to /opt/local/lib, and why they are targeting x64 on ARM Mac.

madame-rachelle commented 6 months ago

Turns out it was either MacPorts or HomeBrew, I installed most of the stuff, other than keeping pkg-config.