1

I have Matlab R2013a and Visual Studio 2010. I am trying to compile flann library 1.8.4 source code by cmake, but I get an error during building INSTALL project in Visual Studio in Release mode as suggested. Since the error is in compiling nearest_neighbors.cpp, I have pasted the lines from mex_nearest_neighbors.log below. Do you know what is the error? Thanks

Build started 07-Oct-15 5:59:12 PM.

1>Project "F:\flann-1.8.4-src\build32\src\matlab\mex_nearest_neighbors.vcxproj" on node 3 (Build target(s)).

1>CustomBuild:

Building Custom Rule F:/flann-1.8.4-src/src/matlab/CMakeLists.txt

CMake does not need to re-run because F:\flann-1.8.4-src\build32\src\matlab\CMakeFiles\generate.stamp is up-to-date.

Building MEX extension F:/flann-1.8.4-src/build32/src/matlab/nearest_neighbors.mexw64

1>cl : Command line warning D9024: unrecognized source file type '$/c', object file assumed nearest_neighbors.cpp

1>F:/flann-1.8.4-src/src/cpp\flann/util/saving.h(111): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

1>F:/flann-1.8.4-src/src/cpp\flann/util/allocator.h(199): warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data

1>F:/flann-1.8.4-src/src/cpp\flann/util/random.h(82): warning C4244: 'argument' : conversion from 'ptrdiff_t' to 'int', possible loss of data

1>F:/flann-1.8.4-src/src/cpp\flann/util/lsh_table.h(446): warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int', possible loss of data

1>F:/flann-1.8.4-src/src/cpp\flann/util/lsh_table.h(454): warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int', possible loss of data

1>F:\flann-1.8.4-src\src\matlab\nearest_neighbors.cpp(147): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

1>F:\flann-1.8.4-src\src\matlab\nearest_neighbors.cpp(148): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

1>F:\flann-1.8.4-src\src\matlab\nearest_neighbors.cpp(149): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

1>F:\flann-1.8.4-src\src\matlab\nearest_neighbors.cpp(253): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

1>F:\flann-1.8.4-src\src\matlab\nearest_neighbors.cpp(352): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

1>F:\flann-1.8.4-src\src\matlab\nearest_neighbors.cpp(353): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

1>F:\flann-1.8.4-src\src\matlab\nearest_neighbors.cpp(540): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

1>F:\flann-1.8.4-src\src\matlab\nearest_neighbors.cpp(541): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

1>F:/flann-1.8.4-src/src/cpp\flann/util/lsh_table.h(262): warning C4267: '=' : conversion from 'size_t' to 'unsigned int', possible loss of data

F:/flann-1.8.4-src/src/cpp\flann/util/lsh_table.h(260) : while compiling class template member function 'void flann::lsh::LshTable::initialize(size_t)' with [ ElementType=unsigned char ]

F:/flann-1.8.4-src/src/cpp\flann/util/lsh_table.h(360) : see reference to function template instantiation 'void flann::lsh::LshTable::initialize(size_t)' being compiled with [ ElementType=unsigned char ]

F:/flann-1.8.4-src/src/cpp\flann/util/lsh_table.h(358) : see reference to class template instantiation 'flann::lsh::LshTable' being compiled with [ ElementType=unsigned char ]

1>LINK : fatal error LNK1181: cannot open input file '$/c.obj'

1>C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL : error : Compile of 'F:\flann-1.8.4-src\src\matlab\nearest_neighbors.cpp' failed.

1>Done Building Project "F:\flann-1.8.4-src\build32\src\matlab\mex_nearest_neighbors.vcxproj" (Build target(s)) -- FAILED.

Build FAILED.

Time Elapsed 00:00:04.48

After visual studio points out error in compiling mex_nearest_neighbors.cpp , the lines below show the following error, but this is probably because visual studio does not build nearest_neighbors.mexw64 from nearest_neighbors.cpp.

10> CMake Error at src/matlab/cmake_install.cmake:31 (file):

10> file INSTALL cannot find

10> "F:/flann-1.8.4-src/build/src/matlab/nearest_neighbors.mexw64".

10> Call Stack (most recent call first):

10> src/cmake_install.cmake:33 (include)

10> cmake_install.cmake:40 (include)

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5):error MSB3073: The command "setlocal

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5):error MSB3073: "C:\Program Files (x86)\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5):error MSB3073: if %errorlevel% neq 0 goto :cmEnd

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5):error MSB3073: :cmEnd

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5):error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5):error MSB3073: :cmErrorLevel

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5):error MSB3073: exit /b %1

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5): error MSB3073: :cmDone

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd

10>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5): error MSB3073: :VCEnd" exited with code 1.

Below, I have added the code for the CMakeLists.txt in ..\flann-1.8.4-src\src\matlab:

#IF(WIN32)
#    SET(MEXEXT_CMD cmd /C mexext)
#ELSE(WIN32)
#    SET(MEXEXT_CMD mexext)
#ENDIF(WIN32)

SET(MEX_NAME nearest_neighbors)

if(WIN32)
    find_program(MEX_CMD mex.bat)
    find_program(MEXEXT_CMD mexext.bat)
else()
    find_program(MEX_CMD mex)
    find_program(MEXEXT_CMD mexext)
endif()

find_program(OCT_CMD mkoctfile)

if(MEX_CMD AND MEXEXT_CMD)

get_filename_component(MEX_REAL_CMD ${MEX_CMD} ABSOLUTE)
get_filename_component(MEX_PATH ${MEX_REAL_CMD} PATH)

get_filename_component(MEXEXT_REAL_CMD ${MEXEXT_CMD} ABSOLUTE)
get_filename_component(MEXEXT_PATH ${MEXEXT_REAL_CMD} PATH)

if (MEX_PATH STREQUAL MEXEXT_PATH)
    message(STATUS "Found MATLAB at: " ${MEX_PATH})

    EXECUTE_PROCESS(COMMAND ${MEXEXT_REAL_CMD} OUTPUT_VARIABLE MEX_EXTENSION OUTPUT_STRIP_TRAILING_WHITESPACE)
    SET(MEX_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MEX_NAME}.${MEX_EXTENSION})

    if (WIN32)
        set(MEX_BUILD_FLAGS "COMPFLAGS=\"$$COMPFLAGS ${OpenMP_CXX_FLAGS}\" LINKFLAGS=\"$$LINKFLAGS ${OpenMP_CXX_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}\"")
    else()
        set(MEX_BUILD_FLAGS "CFLAGS='$$CFLAGS ${OpenMP_CXX_FLAGS}' LDFLAGS='$$LDFLAGS ${OpenMP_CXX_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}'")
    endif()
    separate_arguments(MEX_BUILD_FLAGS)

    ADD_CUSTOM_COMMAND(
        OUTPUT ${MEX_FILE}
        COMMAND ${MEX_REAL_CMD}
        ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp -I${PROJECT_SOURCE_DIR}/src/cpp -L${LIBRARY_OUTPUT_PATH} -lflann_s ${MEX_BUILD_FLAGS}
        DEPENDS flann_s ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp
        COMMENT "Building MEX extension ${MEX_FILE}"
    )

    ADD_CUSTOM_TARGET(mex_${MEX_NAME} ALL DEPENDS ${MEX_FILE})

    FILE(GLOB MATLAB_SOURCES *.m)

    INSTALL (
        FILES ${MEX_FILE} ${MATLAB_SOURCES}
        DESTINATION share/flann/matlab
    )
else()
    message(WARNING "The 'mex' and 'mexext' programs have been found in different locations. It's likely that one of them is not part of the MATLAB instalation. Make sure that the 'bin' directory from the MATLAB instalation is in PATH")
    set(BUILD_MATLAB_BINDINGS OFF) 
endif()
elseif(OCT_CMD)
  SET(MEX_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MEX_NAME}.mex)
  ADD_CUSTOM_COMMAND(
    OUTPUT ${MEX_FILE}
    COMMAND ${OCT_CMD}
    ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp -I${PROJECT_SOURCE_DIR}/src/cpp -L${LIBRARY_OUTPUT_PATH} -DFLANN_STATIC -lflann_s --mex
    DEPENDS flann_s ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp
    COMMENT "Building MEX extension ${MEX_FILE}"
)

  ADD_CUSTOM_TARGET(mex_${MEX_NAME} ALL DEPENDS ${MEX_FILE})

  FILE(GLOB MATLAB_SOURCES *.m)

  INSTALL (
    FILES ${MEX_FILE} ${MATLAB_SOURCES}
    DESTINATION share/flann/octave
)
else()
    message(WARNING "Cannot find MATLAB or Octave instalation. Make sure that the 'bin' directory from the MATLAB instalation or that mkoctfile is in PATH")
    set(BUILD_MATLAB_BINDINGS OFF) 
endif()
4

0 回答 0