Skip to content

Commit

Permalink
Properly link to xpress loader even is coin is disabled (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 authored Sep 4, 2024
1 parent 44cfcbb commit f282d02
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/cpp/multisolver_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,19 @@ target_include_directories (solvers
${xpansion_interfaces_path}
)


target_link_libraries(solvers
PUBLIC
${CMAKE_DL_LIBS}
)

#CLP-CBC
if(COIN_OR)
target_link_libraries (solvers
PUBLIC
PRIVATE
Coin::Clp
Coin::Cgl
Coin::CoinUtils
Coin::Osi
Coin::Cbc
${CMAKE_DL_LIBS}
)
endif()
7 changes: 5 additions & 2 deletions src/cpp/multisolver_interface/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include <sstream>
#include <string>

namespace Solver {
class DynamicLibrary;
}
namespace LoadXpress {

#define STRINGIFY2(X) #X
Expand Down Expand Up @@ -141,7 +144,7 @@ std::function<int(XPRSprob prob, int attrib, int* p_value)> XPRSgetintattrib =
XpressLoader::XpressLoader(std::shared_ptr<ILoggerXpansion> logger)
: logger_(std::move(logger)) {}

bool XpressLoader::LoadXpressFunctions(DynamicLibrary* xpress_dynamic_library) {
bool XpressLoader::LoadXpressFunctions(Solver::DynamicLibrary* xpress_dynamic_library) {
// This was generated with the parse_header_xpress.py script.
// See the comment at the top of the script.

Expand Down Expand Up @@ -299,7 +302,7 @@ bool XpressLoader::LoadXpressDynamicLibrary(std::string& xpresspath) {
static std::string xpress_lib_path;
static std::once_flag xpress_loading_done;
static bool ret;
static DynamicLibrary xpress_library;
static Solver::DynamicLibrary xpress_library;
// static std::mutex mutex;

// mutex.lock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <dlfcn.h>
#endif

namespace Solver {
class DynamicLibrary {
static constexpr size_t kMaxFunctionsNotFound = 10;

Expand Down Expand Up @@ -111,5 +112,6 @@ class DynamicLibrary {
}
};
};
}

#endif // OR_TOOLS_BASE_DYNAMIC_LIBRARY_H_
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class XpressLoader {
std::vector<std::string> XpressDynamicLibraryPotentialPaths();
std::string GetXpressVarFromEnvironmentVariables(const char* XPRESS_var,
bool verbose = true);
bool LoadXpressFunctions(DynamicLibrary* xpress_dynamic_library);
bool LoadXpressFunctions(Solver::DynamicLibrary* xpress_dynamic_library);
int loadLicence(const std::string& lib_path, bool verbose);
};

Expand Down

0 comments on commit f282d02

Please sign in to comment.