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

Install issues with make install_cc #3455

Closed
kevinsouthxu opened this issue Sep 10, 2022 · 6 comments
Closed

Install issues with make install_cc #3455

kevinsouthxu opened this issue Sep 10, 2022 · 6 comments
Assignees
Labels
Doc: Optimization Site Issue related to https://developers.google.com/optimization/ or Documentation in general Lang: C++ Native implementation issue
Milestone

Comments

@kevinsouthxu
Copy link

I build the or-tools with master branch by

git clone -b master https://github.com/google/or-tools

but when I enter

make install_cc

it occurs

make: *** No rule to make target 'install_cc'.  Stop.

How do I handle this issue?

@kevinsouthxu
Copy link
Author

The operating system is Ubuntu 18.04 with a amazon instance p3.8xlarge

@lperron
Copy link
Collaborator

lperron commented Sep 10, 2022

Make install_cpp ?

@kevinsouthxu
Copy link
Author

Make install_cpp ?

it's also

make: *** No rule to make target 'install_cpp'.  Stop.

@pandermatt
Copy link

Looks like they renamed it to cpp # Build C++ OR-Tools library

make cpp

you can use make | grep cpp to list all cpp available commands

But I would recommend using the binary files, which are easier to work with: https://developers.google.com/optimization/install/cpp/linux

@Mizux
Copy link
Collaborator

Mizux commented Sep 22, 2022

Few thinks,

  1. Everything is still in the migration process from Makefile to CMake.
  2. yes, I renamed it "cpp" for consistency.
  3. you can see all C++ available command using help_cpp target.
    %make help_cpp
    Use one of the following C++ targets:
    help_cpp            Generate list of C++ targets with descriptions.
    detect_cpp          Show variables used to build C++ OR-Tools.
    third_party         Build OR-Tools Prerequisite
    cpp                 Build C++ OR-Tools library.
    check_cpp           Run all C++ OR-Tools samples and examples targets.
    test_cpp            Run all C++ OR-Tools test targets.
    test_fz             Run all Flatzinc test targets.
    archive_cpp         Add C++ OR-Tools to archive.
    clean_cpp           Clean C++ output from previous build.
    build               Build a C++ program.
    run                 Run a C++ program.
    test_cpp_algorithms_samples             Build and Run all C++ Algorithms Samples (located in ortools/algorithms/samples)
    test_cpp_graph_samples                  Build and Run all C++ Graph Samples (located in ortools/graph/samples)
    test_cpp_constraint_solver_samples      Build and Run all C++ CP Samples (located in ortools/constraint_solver/samples)
    test_cpp_linear_solver_samples          Build and Run all C++ LP Samples (located in ortools/linear_solver/samples)
    test_cc_model_builder_samples           Build and Run all C++ CP Samples (located in ortools/model_builder/samples)
    test_cpp_sat_samples                    Build and Run all C++ Sat Samples (located in ortools/sat/samples)
    test_cc_tests       Build and Run all C++ Tests (located in ortools/examples/tests)
    test_cc_contrib     Build and Run all C++ Contrib (located in ortools/examples/contrib)
    test_cc_cpp         Build and Run all C++ Examples (located in ortools/examples/cpp)
    test_archive_cpp    Test C++ OR-Tools archive is OK.
  4. now Make only call the CMake based build under the hood
    see:
    third_party:
    cmake -S . -B $(BUILD_DIR) -DBUILD_DEPS=ON \
    -DBUILD_DOTNET=$(BUILD_DOTNET) \
    -DBUILD_JAVA=$(BUILD_JAVA) \
    -DBUILD_PYTHON=$(BUILD_PYTHON) \
    -DBUILD_EXAMPLES=OFF \
    -DBUILD_SAMPLES=OFF \
    -DUSE_COINOR=$(USE_COINOR) \
    -DUSE_GLPK=$(USE_GLPK) \
    -DUSE_PDLP=$(USE_PDLP) \
    -DUSE_SCIP=$(USE_SCIP) \
    -DUSE_CPLEX=$(USE_CPLEX) \
    -DUSE_XPRESS=$(USE_XPRESS) \
    -DUSE_DOTNET_CORE_31=$(USE_DOTNET_CORE_31) \
    -DUSE_DOTNET_6=$(USE_DOTNET_6) \
    -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
    -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) \
    $(CMAKE_ARGS) \
    -G $(GENERATOR)
    # OR Tools unique library.
    cpp:
    $(MAKE) third_party
    cmake --build $(BUILD_DIR) --target install --config $(BUILD_TYPE) -j $(JOBS) -v

    BUILD_DIR := $(OR_ROOT)build_make
    INSTALL_DIR ?= $(OR_ROOT)install_make
  5. So you can notice that now we perform a local install in install_make directory to avoid to pollute user system.
  6. If you want to perform a system wide install, you should use CMake directly and remove the -DCMAKE_INSTALL_PREFIX= directive
    see: https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html
  7. FYI, when build/run C++ test we actually create a CMake project which depends on install_make to found libortools.
    ifeq ($(SOURCE_SUFFIX),.cc) # Those rules will be used if SOURCE contain a .cc file
    SOURCE_PROJECT_DIR := $(SOURCE)
    SOURCE_PROJECT_DIR := $(subst /$(SOURCE_NAME).cc,, $(SOURCE_PROJECT_DIR))
    SOURCE_PROJECT_PATH = $(subst /,$S,$(SOURCE_PROJECT_DIR))
    $(TEMP_CPP_DIR)/$(SOURCE_NAME): | $(TEMP_CPP_DIR)
    $(MKDIR) $(TEMP_CPP_DIR)$S$(SOURCE_NAME)
    $(TEMP_CPP_DIR)/$(SOURCE_NAME)/CMakeLists.txt: ${SRC_DIR}/ortools/cpp/CMakeLists.txt.in | $(TEMP_CPP_DIR)/$(SOURCE_NAME)
    $(COPY) ortools$Scpp$SCMakeLists.txt.in $(TEMP_CPP_DIR)$S$(SOURCE_NAME)$SCMakeLists.txt
    $(SED) -i -e 's/@CPP_NAME@/$(SOURCE_NAME)/' \
    $(TEMP_CPP_DIR)$S$(SOURCE_NAME)$SCMakeLists.txt
    $(SED) -i -e 's/@CPP_FILE_NAME@/$(SOURCE_NAME).cc/' \
    $(TEMP_CPP_DIR)$S$(SOURCE_NAME)$SCMakeLists.txt
    $(SED) -i -e 's;@TEST_ARGS@;$(ARGS);' \
    $(TEMP_CPP_DIR)$S$(SOURCE_NAME)$SCMakeLists.txt
    .PHONY: build # Build a C++ program.
    build: cpp \
    $(SOURCE) \
    $(TEMP_CPP_DIR)/$(SOURCE_NAME)/CMakeLists.txt
    -$(DELREC) $(TEMP_CPP_DIR)$S$(SOURCE_NAME)$Sbuild
    $(COPY) $(subst /,$S,$(SOURCE)) $(TEMP_CPP_DIR)$S$(SOURCE_NAME)$S$(SOURCE_NAME).cc
    cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) &&\
    cmake -S. -Bbuild \
    -DCMAKE_PREFIX_PATH=$(OR_ROOT_FULL)/$(INSTALL_DIR) \
    -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
    -G $(GENERATOR) \
    $(CMAKE_ARGS)
    ifneq ($(PLATFORM),WIN64)
    cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target all -v
    else
    cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target ALL_BUILD -v
    endif
    .PHONY: run # Run a C++ program.
    run: build
    ifneq ($(PLATFORM),WIN64)
    cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target test -v
    else
    cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target RUN_TESTS -v
    endif
    endif

    note: see the line 175 -DCMAKE_PREFIX_PATH=$(OR_ROOT_FULL)/$(INSTALL_DIR) so our generated CMake project will be able to find_package(ortools) to find our locally installed ortools inside the install_make directory...

@Mizux Mizux self-assigned this Sep 22, 2022
@Mizux Mizux added Doc: Optimization Site Issue related to https://developers.google.com/optimization/ or Documentation in general Lang: C++ Native implementation issue labels Sep 22, 2022
@Mizux Mizux added this to the v9.5 milestone Sep 22, 2022
@lperron
Copy link
Collaborator

lperron commented Nov 22, 2022

Regrouped into

Please follow up there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Doc: Optimization Site Issue related to https://developers.google.com/optimization/ or Documentation in general Lang: C++ Native implementation issue
Projects
Archived in project
Development

No branches or pull requests

4 participants