From 88a703f44ff0d6d5d4601584fa77f5ce853025f4 Mon Sep 17 00:00:00 2001 From: Petter Strandmark Date: Thu, 31 Oct 2013 21:13:48 +0100 Subject: [PATCH] Fix compilation in Visual C++ 2013. I had to fix the following things to make Ceres compile in 2013: * Not link to 'm' (GNU math library). * Excplicitly convert an std::ostream to bool. * Include for std::max. Change-Id: I3ff65413baf8711364360d46dd71fd553fa63e72 --- examples/CMakeLists.txt | 6 ++++-- examples/pgm_image.h | 2 +- internal/ceres/test_util.cc | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 28eec9be9..ac96de898 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -41,11 +41,13 @@ ADD_EXECUTABLE(curve_fitting curve_fitting.cc) TARGET_LINK_LIBRARIES(curve_fitting ceres) ADD_EXECUTABLE(curve_fitting_c curve_fitting.c) +TARGET_LINK_LIBRARIES(curve_fitting_c ceres) # As this is a C file #including we have to explicitly add the math # library (libm). Although some compilers (dependent upon options) will accept # the indirect link to libm via Ceres, at least GCC 4.8 on pure Debian won't. -TARGET_LINK_LIBRARIES(curve_fitting_c ceres m) - +IF (NOT MSVC) + TARGET_LINK_LIBRARIES(curve_fitting_c m) +ENDIF (NOT MSVC) ADD_EXECUTABLE(robust_curve_fitting robust_curve_fitting.cc) TARGET_LINK_LIBRARIES(robust_curve_fitting ceres) diff --git a/examples/pgm_image.h b/examples/pgm_image.h index 15e99e469..1328d7594 100644 --- a/examples/pgm_image.h +++ b/examples/pgm_image.h @@ -197,7 +197,7 @@ bool PGMImage::WriteToFile(std::string filename) const { outputfile << static_cast(data_[i] + 0.5) << ' '; } - return outputfile; // Returns true/false + return bool(outputfile); // Returns true/false } namespace { diff --git a/internal/ceres/test_util.cc b/internal/ceres/test_util.cc index a3f67bdd3..8af48abbd 100644 --- a/internal/ceres/test_util.cc +++ b/internal/ceres/test_util.cc @@ -30,6 +30,7 @@ // // Utility functions useful for testing. +#include #include #include "ceres/file.h" #include "ceres/stringprintf.h"