465{
466 std::vector<std::string> lib_paths;
467
468 std::string ld_library_path =
safe_getenv(
"LD_LIBRARY_PATH");
469 if (!ld_library_path.empty()) {
470 std::istringstream stream(ld_library_path);
471 std::string path;
472 while (std::getline(stream, path, ':')) {
473 if (!path.empty() && fs::exists(path)) {
474 lib_paths.push_back(path);
475 }
476 }
477 }
478
479 std::vector<std::string> default_paths = {
480#if defined(MAYAFLUX_PLATFORM_MACOS) && (defined(__aarch64__) || defined(_M_ARM64))
481 "/opt/homebrew/lib",
482#endif
483 "/usr/local/lib",
484 "/usr/lib",
485 "/lib",
486 "/usr/local/lib64",
487 "/usr/lib64",
488 "/lib64"
489 };
490
491 for (const auto& path : default_paths) {
492 if (fs::exists(path)) {
493 lib_paths.push_back(path);
494 }
495 }
496
497 return lib_paths;
498}