Macedon971
Macedon971

Reputation: 335

Not able to compile C source files using make. CMake error Cannot find source files but they are there

Im trying to compile the posest C++ library posest : A C/C++ Library for Robust 6DoF Pose Estimation from 3D-2D Correspondences with make. But when run the make I got the following error

make
-- LEVMAR_INCLUDE_DIR = /usr/local/levmar-2.6
-- LEVMAR_BINARY_DIR = /usr/local/levmar-2.6/w32
-- LAPACKBLAS_DIR = /usr/lib
-- demos will be linked against posest;levmar;lapack;blas;f2c
-- Configuring done
CMake Error at CMakeLists.txt:24 (ADD_LIBRARY):
  Cannot find source file:

    mlsl/mlsl.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Warning (dev) at CMakeLists.txt:65 (ADD_DEPENDENCIES):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "levmar" of target "binocposest_demo" does not exist.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at CMakeLists.txt:64 (ADD_DEPENDENCIES):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "levmar" of target "posest_demo" does not exist.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error: Cannot determine link language for target "posest".
CMake Error: CMake can not determine linker language for target: posest
-- Generating done
-- Build files have been written to: /home/admini/posest-1.2
Makefile:714: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1

But the source file mlsl.c is already there

Here is the contents of the CMakeList.txt file

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(POSEST)

# levmar library
SET(LEVMAR_INCLUDE_DIR "/usr/local/levmar-2.6" CACHE PATH "Path to LEVMAR library header")
#ADD_SUBDIRECTORY(${LEVMAR_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${LEVMAR_INCLUDE_DIR})
MESSAGE(STATUS "LEVMAR_INCLUDE_DIR = ${LEVMAR_INCLUDE_DIR}")

IF(MSVC)
  ADD_DEFINITIONS(/arch:SSE2)
  # get rid of CRT warnings
  ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(MSVC)

INCLUDE_DIRECTORIES(mlsl)

ADD_LIBRARY(posest buckets.c lqs.c ransac.c rngs.c prosac.c deal.c p3p.c p4pf.c planep4p.c svd3.c polysolve.c
  poseproj.c posest.c align.c lhm.c sam.c compiler.h lqs.h ransac.h prosac.h p3p.h p4pf.h planep4p.h svd3.h
  polysolve.h poseproj.h posest.h util.h rngs.h sam.h
  mlsl/mlsl.c mlsl/mt19937ar.c mlsl/redblack.c mlsl/sobolseq.c
)

OPTION(BUILD_DEMOS "Build demo programs?" TRUE)

# demo program
IF(BUILD_DEMOS)
  # paths to levmar & lapack/blas libraries
  SET(LEVMAR_BINARY_DIR "${LEVMAR_INCLUDE_DIR}/w32" CACHE PATH "Path to levmar library")
  MESSAGE(STATUS "LEVMAR_BINARY_DIR = ${LEVMAR_BINARY_DIR}")

  SET(LAPACKBLAS_DIR "/usr/lib" CACHE PATH "Path to lapack/blas libraries")
  MESSAGE(STATUS "LAPACKBLAS_DIR = ${LAPACKBLAS_DIR}")


  # actual names for the lapack/blas/f2c libraries
  SET(LAPACKBLAS_LIB_NAMES "lapack;blas" CACHE STRING "The name of the lapack & blas libraries")
  SET(F2C_LIB_NAME f2c CACHE STRING "The name of the f2c or F77/I77 library")
  # f2c is sometimes equivalent to libF77 & libI77
  #SET(F2C_LIB_NAME "libF77;libI77" CACHE STRING "The name of the f2c or F77/I77 library")

  SET(LIBS posest levmar)
  SET(LIBS ${LIBS} ${LAPACKBLAS_LIB_NAMES} ${F2C_LIB_NAME})

  LINK_DIRECTORIES(${CMAKE_BINARY_DIR}) # location of the posest library
  LINK_DIRECTORIES(${LEVMAR_BINARY_DIR}) # location of the levmar library
  LINK_DIRECTORIES(${LAPACKBLAS_DIR})

  ADD_EXECUTABLE(posest_demo posest_demo.c)
  TARGET_LINK_LIBRARIES(posest_demo ${LIBS})

  ADD_EXECUTABLE(binocposest_demo binocposest_demo.c)
  TARGET_LINK_LIBRARIES(binocposest_demo ${LIBS})

  MESSAGE(STATUS "demos will be linked against ${LIBS}")

# make sure that the libraries are built before the demos
  ADD_DEPENDENCIES(posest_demo posest levmar)
  ADD_DEPENDENCIES(binocposest_demo posest levmar)
ENDIF(BUILD_DEMOS)

Here the Project Directory screenshot. Project directory

And the content of the mlsl directory

/home/posest-1.2/mlsl/mlsl.c
/home/posest-1.2/mlsl/mlsl.h
/home/posest-1.2/mlsl/mt19937ar.c
/home/posest-1.2/mlsl/mt19937ar.h
/home/posest-1.2/mlsl/redblack.c
/home/posest-1.2/mlsl/redblack.h
/home/posest-1.2/mlsl/sobol.h
/home/posest-1.2/mlsl/soboldata.h
/home/posest-1.2/mlsl/sobolseq.c

Im not sure what is the problem. Any help?

Upvotes: 0

Views: 353

Answers (1)

fdk1342
fdk1342

Reputation: 3564

I had to download the tar file from the website. It is malformed and won't work.

~/swdev/posest-1.2$ ls -ld mlsl/
drw-r--r-- 2 XXX XXXX 4096 Oct  6  2014 mlsl/
~/swdev/posest-1.2$ chmod u+x mlsl/
~/swdev/posest-1.2$ cmake .

The sources and directories are required to be readable. In this case mlsl has incorrect permissions and CMake cannot read the file. Use the chmod command to fix the permissions on the directory.

Upvotes: 1

Related Questions