Original issue 3 created by sandwichmaker on 2012-05-02T00:39:42.000Z:
What steps will reproduce the problem?
- On a system where BLAS and LAPACK are not in the same library (like Ubuntu 12.04), attempt to build ceres-solver using CMake.
What is the expected output? What do you see instead?
Expected: ceres-solver builds successfully.
Instead: Several objects and tests fail to link on account of unresolved references in libcholmod to libblas symbols.
Linking CXX executable levenberg_marquardt_test
/usr/local/lib/libcholmod.a(cholmod_super_numeric.o):cholmod_super_numeric.c:function cholmod_super_numeric: error: undefined reference to 'dsyrk_'
/usr/local/lib/libcholmod.a(cholmod_super_numeric.o):cholmod_super_numeric.c:function cholmod_super_numeric: error: undefined reference to 'dgemm_'
/usr/local/lib/libcholmod.a(cholmod_super_numeric.o):cholmod_super_numeric.c:function cholmod_super_numeric: error: undefined reference to 'dtrsm_'
/usr/local/lib/libcholmod.a(cholmod_super_numeric.o):cholmod_super_numeric.c:function cholmod_super_numeric: error: undefined reference to 'zherk_'
/usr/local/lib/libcholmod.a(cholmod_super_numeric.o):cholmod_super_numeric.c:function cholmod_super_numeric: error: undefined reference to 'zgemm_'
/usr/local/lib/libcholmod.a(cholmod_super_numeric.o):cholmod_super_numeric.c:function cholmod_super_numeric: error: undefined reference to 'ztrsm_'
/usr/local/lib/libcholmod.a(cholmod_super_numeric.o):cholmod_super_numeric.c:function cholmod_super_numeric: error: undefined reference to 'zherk_'
/usr/local/lib/libcholmod.a(cholmod_super_numeric.o):cholmod_super_numeric.c:function cholmod_super_numeric: error: undefined reference to 'zgemm_'
/usr/local/lib/libcholmod.a(cholmod_super_numeric.o):cholmod_super_numeric.c:function cholmod_super_numeric: error: undefined reference to 'ztrsm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'dtrsm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'dgemm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'dtrsm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'dtrsv_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'dgemv_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'ztrsm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'zgemm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'ztrsm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'ztrsv_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_lsolve: error: undefined reference to 'zgemv_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_ltsolve: error: undefined reference to 'dgemm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_ltsolve: error: undefined reference to 'dtrsm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_ltsolve: error: undefined reference to 'dgemv_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_ltsolve: error: undefined reference to 'dtrsv_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_ltsolve: error: undefined reference to 'zgemm_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_ltsolve: error: undefined reference to 'zgemv_'
/usr/local/lib/libcholmod.a(cholmod_super_solve.o):cholmod_super_solve.c:function cholmod_super_ltsolve: error: undefined reference to 'ztrsv_'
What version of the product are you using? On what operating system?
git commit 17fbc8e, Ubuntu 12.04.
Please provide any additional information below.
It's possible that this is an artifact of my build environment, and libcholmod.a shouldn't depend on libblas.a, but on my system it does, and my build process for SuiteSparse was pretty vanilla.
Assuming there is a dependence, the current version will work fine on OS X because BLAS and LAPACK are contained in one library (vecLib), as noted in a comment in CMakeLists.txt. For Linux and others, the following patch sorts things out. In this patch, the BLAS check will only happen on non-APPLE platforms.
Once the patches from Issues 1-3 are applied, ceres-solver builds with no warnings on Ubuntu 12.04 using gcc/g++ 4.6.3.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a9cecc..43a500c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -137,6 +137,13 @@ IF (SUITESPARSE)
FIND_LIBRARY(LAPACK_LIB NAMES vecLib)
ELSE (APPLE)
FIND_LIBRARY(LAPACK_LIB NAMES lapack)
- FIND_LIBRARY(BLAS_LIB NAMES blas)
- IF (NOT EXISTS ${BLAS_LIB})
- MESSAGE(FATAL_ERROR
-
"Can't find BLAS "
-
"Please specify -DBLAS_LIB=...")
- ENDIF (NOT EXISTS ${BLAS_LIB})
- MESSAGE ("-- Found BLAS library: ${BLAS_LIB}")
ENDIF (APPLE)
IF (NOT EXISTS ${LAPACK_LIB})
@@ -145,7 +152,6 @@ IF (SUITESPARSE)
"Please specify -DLAPACK_LIB=...")
ENDIF (NOT EXISTS ${LAPACK_LIB})
MESSAGE ("-- Found LAPACK library: ${LAPACK_LIB}")
ELSE (SUITESPARSE)
ADD_DEFINITIONS(-DCERES_NO_SUITESPARSE)
ENDIF (SUITESPARSE)
diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt
index 8c4023e..92b30ee 100644
--- a/internal/ceres/CMakeLists.txt
+++ b/internal/ceres/CMakeLists.txt
@@ -108,14 +108,15 @@ ADD_LIBRARY(ceres
${GLOG_LIB}
${GFLAGS_LIB}
${LAPACK_LIB}
- ${BLAS_LIB}
${CAMD_LIB}
${AMD_LIB}
${CCOLAMD_LIB}