[CMake] Compiling dll under MSVC 2008

Mike Jackson mike.jackson at bluequartz.net
Thu Apr 16 13:48:03 EDT 2009


You will want to read this link
<http://www.cmake.org/Wiki/BuildingWinDLL>

which should explain everything you need to know.

Mike Jackson

PS: Feedback on that article is also welcome.

On Thu, Apr 16, 2009 at 1:39 PM, Benoit <benpaka.spam at gmail.com> wrote:
> Hello,
>
> I've a problem when using libraries under MS Visual C++ 2008 Express Edition
> but it works fine with GCC and MinGW.
>
> I have first create a core (cv7core) library that compile correctly (I
> obtain cv7core.dll), however I doesn't create the static lib.
> Then I create another library that use the first one but it doesn't compile
> because it doesn't find the cv7core.lib:
>
> LINK : fatal error LNK1104: no se puede abrir el archivo
> '..\cv7core\Debug\cv7core.lib'
>
> My CmakeLists.txt have the following interesant part:
>
>
> ------------------------------------------------------------------------------
> ./CmakeLists.txt:
> ------------------------------------------------------------------------------
> ...
> ## On DLL platform put also *.dll
> SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
>  ${PROJECT_INSTALL_PATH}/bin
>  CACHE PATH
>  "Single Directory for all Executables and DLL."
> )
>
> ## Otherwise put library in lib folder.
> SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
>  ${PROJECT_INSTALL_PATH}/lib
>  CACHE PATH
>   "Single Directory for all Libraries"
> )
> ...
>
>
> ------------------------------------------------------------------------------
> ./src/cv7core/CmakeLists.txt:
> ------------------------------------------------------------------------------
> set(LIBNAME "cv7core")
> set(SRC_FILES  cv7BGModel.c cv7ConCompo.c ...)
> include_directories(${OpenCV_INCLUDE_DIRS})
> include_directories(${PROJECT_SOURCE_DIR}/include/${LIBNAME})
>
> # change lib_target properties
> SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES
> VERSION ${${PROJECT_NAME}_MINOR_VERSION}
> SOVERSION ${${PROJECT_NAME}_MINOR_VERSION}
> #CLEAN_DIRECT_OUTPUT 1 # avoid conflicts between library and binary target
> names
> #OUTPUT_NAME ${LIBNAME} # allow creating static and shared libs without
> conflicts
> )
>
>
> It is maybe a very stupid things but i'm not microsoft friendly and it is
> the first time i use the MSVC compilator
>
> --
> Benoit RAT
> www.neub.co.nr
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list