Skip to content

Commit

Permalink
fix gurobi on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jgillis committed Mar 18, 2023
1 parent 9921c68 commit 462e208
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions gurobi/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,28 @@ def function_ptr(decl):
#if defined(_WIN32)
const char library_suffix[] = "dll";
const char library_prefix[] = "";
const char path_env[] = "PATH";
#elif defined(__APPLE__)
const char library_suffix[] = "dylib";
const char library_prefix[] = "lib";
const char path_env[] = "DYLD_LIBRARY_PATH";
#else
const char library_suffix[] = "so";
const char library_prefix[] = "lib";
const char path_env[] = "LD_LIBRARY_PATH";
#endif
if (suffix==NULL) {
snprintf(err_msg, err_msg_len, "Gurobi load adaptor needs an environmental variable <GUROBI_VERSION> "
"such that libgurobi<GUROBI_VERSION>.%s can be found.", library_suffix);
"such that %sgurobi<GUROBI_VERSION>.%s can be found.", library_prefix, library_suffix);
return 1;
}
char buffer[100];
snprintf(buffer, 100, "libgurobi%s.%s", suffix, library_suffix);
snprintf(buffer, 100, "%sgurobi%s.%s", library_prefix, suffix, library_suffix);
#if defined(_WIN32)
h = LoadLibrary(TEXT(buffer));
Expand Down
7 changes: 5 additions & 2 deletions gurobi/src/gurobi.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,28 @@ int (*GRBupdatemodel)(GRBmodel *) = NULL;

#if defined(_WIN32)
const char library_suffix[] = "dll";
const char library_prefix[] = "";
const char path_env[] = "PATH";
#elif defined(__APPLE__)
const char library_suffix[] = "dylib";
const char library_prefix[] = "lib";
const char path_env[] = "DYLD_LIBRARY_PATH";
#else
const char library_suffix[] = "so";
const char library_prefix[] = "lib";
const char path_env[] = "LD_LIBRARY_PATH";
#endif


if (suffix==NULL) {
snprintf(err_msg, err_msg_len, "Gurobi load adaptor needs an environmental variable <GUROBI_VERSION> "
"such that libgurobi<GUROBI_VERSION>.%s can be found.", library_suffix);
"such that %sgurobi<GUROBI_VERSION>.%s can be found.", library_prefix, library_suffix);
return 1;
}

char buffer[100];

snprintf(buffer, 100, "libgurobi%s.%s", suffix, library_suffix);
snprintf(buffer, 100, "%sgurobi%s.%s", library_prefix, suffix, library_suffix);

#if defined(_WIN32)
h = LoadLibrary(TEXT(buffer));
Expand Down

0 comments on commit 462e208

Please sign in to comment.