Hi all,<div><br></div><div>I have been trying to build a project under MSVC which I generated through CMAKE. The same projects compiles correctly  without any error in UBUNTU. But</div><div>when I build the same project under msvc, I get so many linking errors. From the project configuration of msvc project I figured it out that none of libraries are linked.</div>
<div>The project configuration does not contain linker tab, but rather a Librarian tab comes which does not contain any of the linked libraries which I put in TARGET_LINK_LIBRARIES.</div><div><br></div><div>I am relatively new to cmake. Please point out where I am making mistake.</div>
<div><br></div><div>I would put here the root CMakeLists.txt and one subdirectory ./lib/imagelib  CMakeLists.txt</div><div><br></div><div>cmake_minimum_required(VERSION 2.4)</div><div><br></div><div><br></div><div>if(UNIX)</div>
<div>PROJECT(hybridnccsurfacecoloring C CXX Fortran)</div><div>endif(UNIX)</div><div><br></div><div>if(WIN32)</div><div>PROJECT(hybridnccsurfacecoloring C CXX)</div><div>endif(WIN32)</div><div><br></div><div><br></div><div>
ADD_DEFINITIONS(-DNO_BLAS_WRAP)</div><div><br></div><div><br></div><div>SET(OpenCV_DIR &quot;E:/opencv-devel/opencv/release2&quot;)</div><div>#SET(BOOST_ROOT &quot;C:/Program Files/boost/boost_1_45_0&quot;)</div><div>#set (Boost_DEBUG ON)</div>
<div><br></div><div>find_package(OpenCV)</div><div>find_package(ImageMagick COMPONENTS Magick++ MagickCore)</div><div>#find_package(Boost 1.45.0 COMPONENTS filesystem)</div><div><br></div><div><br></div><div>if(OpenCV_FOUND) </div>
<div>message(STATUS &quot;Opencv found.&quot;)</div><div>include_directories(${OpenCV_INCLUDE_DIRS})</div><div>link_libraries(${OpenCV_LIBS})</div><div>ENDIF(OpenCV_FOUND)</div><div><br></div><div>if(ImageMagick_FOUND) </div>
<div>message(STATUS &quot;Image Magick found.&quot;)</div><div>include_directories(${ImageMagick_INCLUDE_DIRS})</div><div>link_libraries(${ImageMagick_LIBRARIES})</div><div>ENDIF(ImageMagick_FOUND)</div><div><br></div><div>
include_directories( &quot;${CMAKE_SOURCE_DIR}/src&quot;</div><div>                     &quot;${CMAKE_SOURCE_DIR}/include&quot;</div><div>                     &quot;${CMAKE_SOURCE_DIR}/lib/imagelib&quot;</div><div>                     &quot;${CMAKE_SOURCE_DIR}/lib/matrix&quot;</div>
<div>                     &quot;${CMAKE_SOURCE_DIR}/lib/5point&quot;</div><div>                     &quot;${CMAKE_SOURCE_DIR}/lib/epnp&quot;</div><div>                     &quot;${CMAKE_SOURCE_DIR}/lib/mathlib&quot;</div>
<div>                     &quot;${CMAKE_SOURCE_DIR}/lib/sba&quot;</div><div>                     &quot;${CMAKE_SOURCE_DIR}/lib/Jhead&quot;</div><div>                     &quot;${CMAKE_SOURCE_DIR}/lib/bundlesrc&quot;</div>
<div>                     &quot;${CMAKE_SOURCE_DIR}/lib/sfm&quot;</div><div>                     &quot;${CMAKE_SOURCE_DIR}/lib/Descriptors&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>     </div>
<div> <span class="Apple-tab-span" style="white-space:pre">                </span>             &quot;C:/downloads/ImageMagick-6.6.2&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>             &quot;C:/Program Files/boost/boost_1_45_0&quot;</div>
<div>                    )</div><div><br></div><div>if(WIN32)</div><div>include_directories(</div><div> &quot;${CMAKE_SOURCE_DIR}/lib/f2c&quot;</div><div> &quot;${CMAKE_SOURCE_DIR}/lib/getopt&quot;</div><div> &quot;${CMAKE_SOURCE_DIR}/lib/jpeg&quot;</div>
<div> &quot;${CMAKE_SOURCE_DIR}/lib/zlib&quot;</div><div> &quot;${CMAKE_SOURCE_DIR}/lib/ann/include&quot;</div><div>)</div><div><br></div><div>endif(WIN32)</div><div><br></div><div><br></div><div>link_libraries(               </div>
<div><br></div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>          &quot;C:/downloads/ImageMagick-6.6.2/VisualMagick/lib/IM_MOD_DB_magick_.lib&quot;</div><div>              &quot;C:/downloads/ImageMagick-6.6.2/VisualMagick/lib/CORE_DB_magick_.lib&quot;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>      &quot;C:/Program Files/boost/boost_1_45_0/stage/lib/libboost_filesystem-vc90-mt-gd-1_45.lib&quot;</div><div>              )</div><div>
<br></div><div><br></div><div><br></div><div>add_executable(  hybridnccsurfacecoloring  src/plyfilewriter.cpp</div><div>                 src/bundler_preprocesser.cpp</div><div>                 src/image_property_extractor.cpp</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>             src/BundleOutputReader.cpp main.cpp)</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>             </div>
<div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>TARGET_LINK_LIBRARIES(hybridnccsurfacecoloring bundler imagelib matrix mathlib </div><div>                      5point libsba  libepnp </div>
<div>                      sfm libDescriptors f2c  minpack lapack ann)</div><div><br></div><div>if(WIN32)</div><div>TARGET_LINK_LIBRARIES(hybridnccsurfacecoloring getopt jpeg)</div><div>endif(WIN32)</div><div><br></div><div>
<br></div><div><br></div><div>add_subdirectory(lib) </div><div><br></div><div><br></div><div><br></div><div>###################################################</div><div><br></div><div>One CMakeLists.txt under ./lib/imagelib</div>
<div><br></div><div><div>include_directories(</div><div>    &quot;.&quot;</div><div>    &quot;../../include&quot;</div><div>    &quot;../imagelib&quot;</div><div>)</div><div><br></div><div><br></div><div>add_library(matrix ./matrix.c svd svd.c vector vector.c)</div>
<div>TARGET_LINK_LIBRARIES(matrix lapack f2c minpack blas)</div></div><div><br></div><div><br></div><div><br></div><div>There are few more libraries under lib folder , some are dependent on others. I have written similar codes for them as above.</div>
<div>They work fine under LINUX but they are giving linker error under windows msvc.</div><div><br></div><div>I would greatly appreciate any help here. </div><div><br></div><div><br></div><div>Thanks</div><div>Avanindra</div>