diff options
author | fireice-uk <fireice-uk@users.noreply.github.com> | 2017-11-02 18:18:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-02 18:18:49 +0000 |
commit | 11f1028782ca62df10a08e6b5907f2f252bc3fc7 (patch) | |
tree | e16f036213c590e884f5d122518e1aff2ee2f83c | |
parent | bc18ee3fd7191d6ba4bc0e5c0d82fb90cc2ded12 (diff) | |
parent | 14f041a971bb450e6eece99efd528afc50421da9 (diff) | |
download | xmr-stak-11f1028782ca62df10a08e6b5907f2f252bc3fc7.zip xmr-stak-11f1028782ca62df10a08e6b5907f2f252bc3fc7.tar.gz |
Merge pull request #86 from psychocrypt/topic-searchBackendLibraries
search for linux backend plugins
-rw-r--r-- | xmrstak/backend/plugin.hpp | 9 | ||||
-rw-r--r-- | xmrstak/cli/cli-miner.cpp | 10 | ||||
-rw-r--r-- | xmrstak/params.hpp | 2 |
3 files changed, 17 insertions, 4 deletions
diff --git a/xmrstak/backend/plugin.hpp b/xmrstak/backend/plugin.hpp index 7ba9e6f..b08ab89 100644 --- a/xmrstak/backend/plugin.hpp +++ b/xmrstak/backend/plugin.hpp @@ -43,7 +43,14 @@ struct plugin // `.dylib` Mac OS X file extention for dynamic libraries fileExtension = ".dylib"; # endif - libBackend = dlopen((params::inst().executablePrefix + "/lib" + libName + fileExtension).c_str(), RTLD_LAZY); + // search library in working directory + libBackend = dlopen(("./lib" + libName + fileExtension).c_str(), RTLD_LAZY); + // fallback to binary directory + if(!libBackend) + libBackend = dlopen((params::inst().executablePrefix + "lib" + libName + fileExtension).c_str(), RTLD_LAZY); + // try use LD_LIBRARY_PATH + if(!libBackend) + libBackend = dlopen(("lib" + libName + fileExtension).c_str(), RTLD_LAZY); if(!libBackend) { std::cerr << "WARNING: "<< m_backendName <<" cannot load backend library: " << dlerror() << std::endl; diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index f571ad6..81639ef 100644 --- a/xmrstak/cli/cli-miner.cpp +++ b/xmrstak/cli/cli-miner.cpp @@ -106,15 +106,21 @@ int main(int argc, char *argv[]) using namespace xmrstak; std::string pathWithName(argv[0]); - auto pos = pathWithName.rfind("/"); + std::string seperator("/"); + auto pos = pathWithName.rfind(seperator); + if(pos == std::string::npos) { // try windows "\" - pos = pathWithName.rfind("\\"); + seperator = "\\"; + pos = pathWithName.rfind(seperator); } params::inst().binaryName = std::string(pathWithName, pos + 1, std::string::npos); if(params::inst().binaryName.compare(pathWithName) != 0) + { params::inst().executablePrefix = std::string(pathWithName, 0, pos); + params::inst().executablePrefix += seperator; + } bool userSetPasswd = false; for(int i = 1; i < argc; ++i) diff --git a/xmrstak/params.hpp b/xmrstak/params.hpp index 6127212..1551378 100644 --- a/xmrstak/params.hpp +++ b/xmrstak/params.hpp @@ -37,7 +37,7 @@ struct params params() : binaryName("xmr-stak"), - executablePrefix("./"), + executablePrefix(""), useAMD(true), useNVIDIA(true), useCPU(true), |