493{
494 std::vector<std::string> lib_paths;
495
496 std::string ld_library_path =
safe_getenv(
"LD_LIBRARY_PATH");
497 if (!ld_library_path.empty()) {
498 std::istringstream stream(ld_library_path);
499 std::string path;
500 while (std::getline(stream, path, ':')) {
501 if (!path.empty() && fs::exists(path)) {
502 lib_paths.push_back(path);
503 }
504 }
505 }
506
507 std::vector<std::string> default_paths = {
508#if defined(MAYAFLUX_PLATFORM_MACOS) && (defined(__aarch64__) || defined(_M_ARM64))
509 "/opt/homebrew/lib",
510#endif
511 "/usr/local/lib",
512 "/usr/lib",
513 "/lib",
514 "/usr/local/lib64",
515 "/usr/lib64",
516 "/lib64"
517 };
518
519 for (const auto& path : default_paths) {
520 if (fs::exists(path)) {
521 lib_paths.push_back(path);
522 }
523 }
524
525 return lib_paths;
526}