Skip to content

Commit

Permalink
no lib prefix for cplex on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jgillis committed Mar 18, 2023
1 parent 5ac1453 commit 9921c68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions cplex/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,27 @@ 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, "CPLEX load adaptor needs an environmental variable <CPLEX_VERSION> "
"such that libcplex<CPLEX_VERSION>.%s can be found.", library_suffix);
"such that %scplex<CPLEX_VERSION>.%s can be found.", library_prefix, library_suffix);
return 1;
}
char buffer[100];
snprintf(buffer, 100, "libcplex%s.%s", suffix, library_suffix);
snprintf(buffer, 100, "%scplex%s.%s", library_prefix, suffix, library_suffix);
#if defined(_WIN32)
h = LoadLibrary(TEXT(buffer));
Expand Down
10 changes: 6 additions & 4 deletions cplex/src/cplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,27 @@ int (*CPXXwriteprob)(CPXCENVptr, CPXCLPptr, char const *, char const *) = 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, "CPLEX load adaptor needs an environmental variable <CPLEX_VERSION> "
"such that libcplex<CPLEX_VERSION>.%s can be found.", library_suffix);
"such that %scplex<CPLEX_VERSION>.%s can be found.", library_prefix, library_suffix);
return 1;
}

char buffer[100];

snprintf(buffer, 100, "libcplex%s.%s", suffix, library_suffix);
snprintf(buffer, 100, "%scplex%s.%s", library_prefix, suffix, library_suffix);

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

0 comments on commit 9921c68

Please sign in to comment.