Hello everyone
I use two crates which are bindings to c++ libraries.
Both c++ libraries link to the same third c++ library they depend on.
When trying to compile the program cargo failed on linking step with the error:
b\\rustlib\\etc\\libstd.natvis"
= note: libllama_cpp_sys_2-1131e8f6e28c8598.rlib(ggml-backend.obj) : error LNK2005: ggml_backend_buft_name already defined in libwhisper_rs_sys-f2fa5877d4809bf3.rlib(ggml-backend.obj)
libllama_cpp_sys_2-1131e8f6e28c8598.rlib(ggml-backend.obj) : error LNK2005: ggml_backend_buft_alloc_buffer already defined in libwhisper_rs_sys-f2fa5877d4809bf3.rlib(ggml-backend.obj)
Seems like both llama-cpp-2 and whisper-rs crates uses ggml library and it failed to compile because of that.
Is there a known cross platform solution for this issue?
I suppose that might be a C++ problem. The solution might be enable dynamic linking, make the 2 C++ library share the same 3rd library.
If you are not an expert of C++, you may open issues in both llama-cpp-2 and whisper-rs crates, let the crate owner update their build script to add the dynamic linking operation.
(I have no idea whether it is correct, but file an issue is always an acceptable option.)
The Rust solution is to create a ggml-backend-sys crate and change both llama-cpp-2 and whisper-rs to import that crate instead of directly linking to the library.
Ah, then yes this would need to be dynamic linking to ggml to resolve the issue at all.
In the mean time while you wait for those projects to get fixed so they can be used in the same program, consider exploring a multi process program design where you split the work across two binaries.