macos: rclaspell: get the dlopen to work
This commit is contained in:
parent
9a9e10c7d6
commit
a58ffa5b81
@ -71,12 +71,16 @@ static std::mutex o_aapi_mutex;
|
|||||||
badnames += #NM + string(" "); \
|
badnames += #NM + string(" "); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *aspell_lib_suffixes[] = {
|
static const vector<string> aspell_lib_suffixes {
|
||||||
".so",
|
#if defined(__APPLE__)
|
||||||
".so.15",
|
".15.dylib",
|
||||||
".so.16"
|
".dylib",
|
||||||
|
#else
|
||||||
|
".so",
|
||||||
|
".so.15",
|
||||||
|
".so.16",
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
static const unsigned int nlibsuffs = sizeof(aspell_lib_suffixes) / sizeof(char *);
|
|
||||||
|
|
||||||
// Stuff that we don't wish to see in the .h (possible sysdeps, etc.)
|
// Stuff that we don't wish to see in the .h (possible sysdeps, etc.)
|
||||||
class AspellData {
|
class AspellData {
|
||||||
@ -160,16 +164,39 @@ bool Aspell::init(string &reason)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Don't know what with Apple and (DY)LD_LIBRARY_PATH. Does not work
|
||||||
|
// So we look in all ../lib in the PATH...
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
vector<string> path;
|
||||||
|
const char *pp = getenv("PATH");
|
||||||
|
if (pp) {
|
||||||
|
stringToTokens(pp, path, ":");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
reason = "Could not open shared library ";
|
reason = "Could not open shared library ";
|
||||||
string libbase("libaspell");
|
string libbase("libaspell");
|
||||||
string lib;
|
string lib;
|
||||||
for (unsigned int i = 0; i < nlibsuffs; i++) {
|
for (const auto& suff : aspell_lib_suffixes) {
|
||||||
lib = libbase + aspell_lib_suffixes[i];
|
lib = libbase + suff;
|
||||||
reason += string("[") + lib + "] ";
|
reason += string("[") + lib + "] ";
|
||||||
if ((m_data->m_handle = dlopen(lib.c_str(), RTLD_LAZY)) != 0) {
|
if ((m_data->m_handle = dlopen(lib.c_str(), RTLD_LAZY)) != 0) {
|
||||||
reason.erase();
|
reason.erase();
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
// Above was the normal lookup: let dlopen search the directories.
|
||||||
|
// Here is for Apple. Also look at all ../lib along the PATH
|
||||||
|
for (const auto& dir : path) {
|
||||||
|
string lib1 = path_canon(dir + "/../lib/" + lib);
|
||||||
|
if ((m_data->m_handle = dlopen(lib1.c_str(), RTLD_LAZY)) != 0) {
|
||||||
|
reason.erase();
|
||||||
|
lib=lib1;
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
found:
|
found:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user