[CMake] TARGET_LINK_LIBRARIES not working for MSVC

Avanindra Singh avanindra.singh at gmail.com
Sat Jan 8 09:15:48 EST 2011


Hi all,

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
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.
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.

I am relatively new to cmake. Please point out where I am making mistake.

I would put here the root CMakeLists.txt and one subdirectory ./lib/imagelib
 CMakeLists.txt

cmake_minimum_required(VERSION 2.4)


if(UNIX)
PROJECT(hybridnccsurfacecoloring C CXX Fortran)
endif(UNIX)

if(WIN32)
PROJECT(hybridnccsurfacecoloring C CXX)
endif(WIN32)


ADD_DEFINITIONS(-DNO_BLAS_WRAP)


SET(OpenCV_DIR "E:/opencv-devel/opencv/release2")
#SET(BOOST_ROOT "C:/Program Files/boost/boost_1_45_0")
#set (Boost_DEBUG ON)

find_package(OpenCV)
find_package(ImageMagick COMPONENTS Magick++ MagickCore)
#find_package(Boost 1.45.0 COMPONENTS filesystem)


if(OpenCV_FOUND)
message(STATUS "Opencv found.")
include_directories(${OpenCV_INCLUDE_DIRS})
link_libraries(${OpenCV_LIBS})
ENDIF(OpenCV_FOUND)

if(ImageMagick_FOUND)
message(STATUS "Image Magick found.")
include_directories(${ImageMagick_INCLUDE_DIRS})
link_libraries(${ImageMagick_LIBRARIES})
ENDIF(ImageMagick_FOUND)

include_directories( "${CMAKE_SOURCE_DIR}/src"
                     "${CMAKE_SOURCE_DIR}/include"
                     "${CMAKE_SOURCE_DIR}/lib/imagelib"
                     "${CMAKE_SOURCE_DIR}/lib/matrix"
                     "${CMAKE_SOURCE_DIR}/lib/5point"
                     "${CMAKE_SOURCE_DIR}/lib/epnp"
                     "${CMAKE_SOURCE_DIR}/lib/mathlib"
                     "${CMAKE_SOURCE_DIR}/lib/sba"
                     "${CMAKE_SOURCE_DIR}/lib/Jhead"
                     "${CMAKE_SOURCE_DIR}/lib/bundlesrc"
                     "${CMAKE_SOURCE_DIR}/lib/sfm"
                     "${CMAKE_SOURCE_DIR}/lib/Descriptors"

              "C:/downloads/ImageMagick-6.6.2"
             "C:/Program Files/boost/boost_1_45_0"
                    )

if(WIN32)
include_directories(
 "${CMAKE_SOURCE_DIR}/lib/f2c"
 "${CMAKE_SOURCE_DIR}/lib/getopt"
 "${CMAKE_SOURCE_DIR}/lib/jpeg"
 "${CMAKE_SOURCE_DIR}/lib/zlib"
 "${CMAKE_SOURCE_DIR}/lib/ann/include"
)

endif(WIN32)


link_libraries(


 "C:/downloads/ImageMagick-6.6.2/VisualMagick/lib/IM_MOD_DB_magick_.lib"

 "C:/downloads/ImageMagick-6.6.2/VisualMagick/lib/CORE_DB_magick_.lib"

      "C:/Program
Files/boost/boost_1_45_0/stage/lib/libboost_filesystem-vc90-mt-gd-1_45.lib"
              )



add_executable(  hybridnccsurfacecoloring  src/plyfilewriter.cpp
                 src/bundler_preprocesser.cpp
                 src/image_property_extractor.cpp
             src/BundleOutputReader.cpp main.cpp)







TARGET_LINK_LIBRARIES(hybridnccsurfacecoloring bundler imagelib matrix
mathlib
                      5point libsba  libepnp
                      sfm libDescriptors f2c  minpack lapack ann)

if(WIN32)
TARGET_LINK_LIBRARIES(hybridnccsurfacecoloring getopt jpeg)
endif(WIN32)



add_subdirectory(lib)



###################################################

One CMakeLists.txt under ./lib/imagelib

include_directories(
    "."
    "../../include"
    "../imagelib"
)


add_library(matrix ./matrix.c svd svd.c vector vector.c)
TARGET_LINK_LIBRARIES(matrix lapack f2c minpack blas)



There are few more libraries under lib folder , some are dependent on
others. I have written similar codes for them as above.
They work fine under LINUX but they are giving linker error under windows
msvc.

I would greatly appreciate any help here.


Thanks
Avanindra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110108/0bf5c1af/attachment.htm>


More information about the CMake mailing list