-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
How to add package or-tools? #3770
Comments
You need to add |
I hope someone can assist me in adding the library, or directly help me add it myself. |
Yes I know, I try For test, can using follow code: #include "ortools/linear_solver/linear_solver.h"
#include "ortools/linear_solver/linear_solver.pb.h"
namespace operations_research {
void RunTest(
MPSolver::OptimizationProblemType optimization_problem_type) {
MPSolver solver("Glop", optimization_problem_type);
MPVariable* const x = solver.MakeNumVar(0.0, 1, "x");
MPVariable* const y = solver.MakeNumVar(0.0, 2, "y");
MPObjective* const objective = solver.MutableObjective();
objective->SetCoefficient(x, 1);
objective->SetCoefficient(y, 1);
objective->SetMaximization();
solver.Solve();
printf("\nSolution:");
printf("\nx = %.1f", x->solution_value());
printf("\ny = %.1f", y->solution_value());
}
void RunExample() {
RunTest(MPSolver::GLOP_LINEAR_PROGRAMMING);
}
}
int main(int argc, char** argv) {
operations_research::RunExample();
return 0;
} |
It's probably a link order issue, you probably have to add links to let xmake know in which order it should link them. |
This may be a large workload if manual linking is required, as it has many dependencies. I just started learning about xmake, maybe there are other solutions, maybe I made some mistakes? |
Check installdir/lib and add_links explicitly: xmake-repo/packages/b/brotli/xmake.lua Line 21 in 79a5f74
However, the package has some external dependencies that need to be added as well |
Its huge project can't be manual linking I guess. (ToT) |
You can try, for example, adding the packages that xrepo already has first package("or-tools")
set_homepage("https://developers.google.com/optimization/")
set_description("Google's Operations Research tools")
set_license("Apache-2.0")
add_urls("https://github.com/google/or-tools/archive/refs/tags/$(version).tar.gz",
"https://github.com/google/or-tools.git")
add_versions("v9.9", "8c17b1b5b05d925ed03685522172ca87c2912891d57a5e0d5dcaeff8f06a4698")
if is_plat("windows") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end
add_deps("cmake")
add_deps("zlib", "eigen", "re2")
add_deps("protobuf-cpp", {confgis = {zlib = true}})
on_install("windows", "linux", "macosx", function (package)
local configs = {
"-DBUILD_TESTING=OFF",
"-DBUILD_EXAMPLES=OFF",
"-DBUILD_SAMPLES=OFF",
"-DBUILD_DEPS=OFF",
"-DUSE_BOP=OFF",
"-DUSE_COINOR=OFF",
"-DUSE_SCIP=OFF",
}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <ortools/linear_solver/linear_solver.h>
void test() {
auto solver = MPSolver::CreateSolver("SCIP");
}
]]}, {configs = {languages = "c++20"}}))
end) |
OK, I will try it late, thank for you kindness help. |
It config success , but build error, when install or-tools. Maybe those deps'version need to specify? |
Is your feature request related to a problem? Please describe.
I found that there are very few packages about Operations Research in xrepo, so I want to add google/or-tools.
I built the or-tools package myself, but encountered a problem. I hope someone can answer it.
It was installed successfully, but there were errors when using it.
Describe the solution you'd like
I added the package myself:
"BUILD_DEPS" means It can auto download requeaments itself by cmake.
The above can be successfully installed
But I get problem when I used, this is my project:
Its build error report:
Describe alternatives you've considered
No response
Additional context
or-tools install user-guide
The text was updated successfully, but these errors were encountered: