10ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# Ceres Solver - A fast non-linear least squares minimizer 20ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# Copyright 2012 Google Inc. All rights reserved. 30ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# http://code.google.com/p/ceres-solver/ 40ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 50ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# Redistribution and use in source and binary forms, with or without 60ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# modification, are permitted provided that the following conditions are met: 70ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 80ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# * Redistributions of source code must retain the above copyright notice, 90ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# this list of conditions and the following disclaimer. 100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# * Redistributions in binary form must reproduce the above copyright notice, 110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# this list of conditions and the following disclaimer in the documentation 120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# and/or other materials provided with the distribution. 130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# * Neither the name of Google Inc. nor the names of its contributors may be 140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# used to endorse or promote products derived from this software without 150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# specific prior written permission. 160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 250ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 260ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 270ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# POSSIBILITY OF SUCH DAMAGE. 280ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 290ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# Author: keir@google.com (Keir Mierle) 300ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 310ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# This is an example Makefile for using Ceres. In practice, the Ceres authors 320ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# suggest using CMake instead, but if Make is needed for some reason, this 330ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# example serves to make it easy to do so. 340ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 350ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# This should point to place where you unpacked or cloned Ceres. 360ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCERES_SRC_DIR := /home/keir/wrk/ceres-extra 370ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 380ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# This should point to the place where you built Ceres. If you got Ceres by 390ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# installing it, then this will likely be /usr/local/lib. 400ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCERES_BIN_DIR := /home/keir/wrk/ceres-extra-bin 410ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 420ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# The place you unpacked or cloned Eigen. If Eigen was installed from packages, 430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# this will likely be /usr/local/include. 440ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongEIGEN_SRC_DIR := /home/keir/src/eigen-3.0.5 450ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 460ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongINCLUDES := -I$(CERES_SRC_DIR)/include \ 470ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong -I$(EIGEN_SRC_DIR) 480ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 490ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCERES_LIBRARY := -lceres 500ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCERES_LIBRARY_PATH := -L$(CERES_BIN_DIR)/lib 510ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCERES_LIBRARY_DEPENDENCIES = -lgflags -lglog 520ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 530ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# If Ceres was built with Suitesparse: 540ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCERES_LIBRARY_DEPENDENCIES += -llapack -lcamd -lamd -lccolamd -lcolamd -lcholmod 550ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# If Ceres was built with CXSparse: 570ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCERES_LIBRARY_DEPENDENCIES += -lcxsparse 580ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 590ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# If Ceres was built with OpenMP: 600ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCERES_LIBRARY_DEPENDENCIES += -fopenmp -lpthread -lgomp -lm 610ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 620ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# The set of object files for your application. 630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongAPPLICATION_OBJS := simple_bundle_adjuster.o 640ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 650ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongall: simple_bundle_adjuster 660ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 670ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongsimple_bundle_adjuster: $(APPLICATION_OBJS) 680ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong g++ \ 690ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong $(APPLICATION_OBJS) \ 700ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong $(CERES_LIBRARY_PATH) \ 710ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong $(CERES_LIBRARY) \ 720ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong $(CERES_LIBRARY_DEPENDENCIES) \ 730ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong -o simple_bundle_adjuster 740ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 750ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# Disabling debug asserts via -DNDEBUG helps make Eigen faster, at the cost of 760ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# not getting handy assert failures when there are issues in your code. 770ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongCFLAGS := -O2 -DNDEBUG 780ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 790ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# If you have files ending in .cpp instead of .cc, fix the next line 800ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# appropriately. 810ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong%.o: %.cc $(DEPS) 820ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong g++ -c -o $@ $< $(CFLAGS) $(INCLUDES) 83