[CMake] Linking error while trying to include an external library to a CMAKE project
maaschn
maaschn at web.de
Sun Apr 28 10:36:37 EDT 2013
I currently try to add an external dynamiced linked library (dll) to my cmake
project. I have got the .dll and the .lib file. I spent a lot of time to
find an answer by myself but I didn't manage to find the solution. The
include works but I always get a linking error when I try to compile a
minimum solution. CMAKE throws no errors while configuring and generating
and finds the library. I hope someone had the problem before and recognizes
my error
I also build my own find module which looks like this
find_path(LLT_INCLUDE_DIR InterfaceLLT_2.h HINTS ${LLT_DIR})
find_library(LLT_LIBRARY NAMES LLT HINTS ${LLT_DIR} )
set(LLT_LIBRARIES ${LLT_LIBRARY} )
set(LLT_INCLUDE_DIRS ${LLT_INCLUDE_DIR} )
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(LLT DEFAULT_MSG LLT_LIBRARY
LLT_INCLUDE_DIR)
mark_as_advanced(LLT_INCLUDE_DIR LLT_LIBRARY )
The corresponding CMakeLists.txt looks like this
PROJECT(TestProg)
cmake_minimum_required(VERSION 2.8)
FIND_PACKAGE(LLT REQUIRED)
INCLUDE_DIRECTORIES(${LLT_INCLUDE_DIR})
SET(TestProg_SOURCES
main.cpp
)
SET(TestProg_HEADERS
)
add_executable(TestProg ${TestProg_SOURCES} ${TestProg_HEADERS})
target_link_libraries(TestProg ${LLT_LIBRARIES} )
Here is the CMAKE output
The C compiler identification is MSVC 16.0.40219.1
The CXX compiler identification is MSVC 16.0.40219.1
Check for working C compiler using: Visual Studio 10
Check for working C compiler using: Visual Studio 10 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 10
Check for working CXX compiler using: Visual Studio 10 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Found LLT: C:/XXX/LLT.lib
Configuring done
Generating done
--
View this message in context: http://cmake.3232098.n2.nabble.com/Linking-error-while-trying-to-include-an-external-library-to-a-CMAKE-project-tp7584264.html
Sent from the CMake mailing list archive at Nabble.com.
More information about the CMake
mailing list