Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix xpress custom install #734

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/cpp/multisolver_interface/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ std::vector<std::string> XpressDynamicLibraryPotentialPaths() {
#if defined(_MSC_VER) // Windows
potential_paths.push_back((prefix / "bin" / "xprs.dll").string());
#elif defined(__APPLE__) // OS X
potential_paths.push_back((prefix / "/lib/libxprs.dylib").string());
potential_paths.push_back((prefix / "lib" / "libxprs.dylib").string());
#elif defined(__GNUC__) // Linux
potential_paths.push_back((prefix / "/lib/libxprs.so").string());
potential_paths.push_back((prefix / "lib" / "libxprs.so").string());
#else
std::cerr << "OS Not recognized by xpress/environment.cc."
<< " You won't be able to use Xpress.";
Expand Down Expand Up @@ -294,7 +294,7 @@ bool LoadXpressDynamicLibrary(std::string& xpresspath) {
for (const std::string& path : canonical_paths) {
if (xpress_library.TryToLoad(path)) {
std::cout << "Info: "
<< "Found the Xpress library in " << path << ".";
<< "Found the Xpress library in " << path << ".\n";
xpress_lib_path.clear();
std::filesystem::path p(path);
p.remove_filename();
Expand Down Expand Up @@ -323,11 +323,11 @@ bool initXpressEnv(bool verbose, int xpress_oem_license_key) {
std::string xpresspath;
bool status = LoadXpressDynamicLibrary(xpresspath);
if (!status) {
std::cout << "Warning: " << status << "\n";
return false;
}

std::string xpress_from_env = GetXpressVarFromEnvironmentVariables("XPRESS");
std::string xpress_from_env =
GetXpressVarFromEnvironmentVariables("XPRESSDIR");
if (xpress_from_env == "") {
if (verbose) {
std::cout << "Warning: Environment variable XPRESS undefined.\n";
Expand All @@ -336,7 +336,7 @@ bool initXpressEnv(bool verbose, int xpress_oem_license_key) {
return false;
}
} else {
xpresspath = xpress_from_env;
xpresspath = (std::filesystem::path(xpress_from_env) / "bin").string();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Xpress documentation advises to call XPRSinit (line 351) with a NULL argument instead of xpresspath. And if we have to use xpresspath it should be preferable to use the environment variable XPAUTH_PATH. As XPAUTH_PATH gives the full path of the license file, we should just get the directory from the full path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the XPRSinit is called with the null argument when the solver is really called(see SolverXpress.cpp)
this function searches Xpress lib :

  • in "standard" place like /opt/xpressmp
  • by looking in the env variable XPRESSDIR
    the whole thing is to not be tied with an xpress version so no need to set the XPAUTH_PATH from xpvars.sh script.
    there is a scenario where the license and binaries are in different places, how would you get the lib, bin from license file?

}

int code;
Expand Down