I am trying to link a chain of external libraries (liblept using libjpeg) to a project. Numerous attempts and searching the internet just caused different cmake errors which is quite confusing
The structure of the project folder:
/Project
|leptonica
|--|include
| |--|leptonica
| | |--|<allheaders.h used by main.cpp is here>
| | |<jpeglib.h used by Leptonica is here>
| |lib
| |--|<.lib files here>
|CMakeLists.txt
|main.cpp
Now, the CMakeLists. The only thing I know about linking these libs is that the basic tips found all around Stack Overflow generate different errors. Except the following:
This gets the project linked, but the application crashes with 0xC0000135
(failed to find the dll).
cmake_minimum_required(VERSION 3.5)
project(Project)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_library(liblept168 STATIC IMPORTED)
set_target_properties(
liblept168
PROPERTIES LINKER_LANGUAGE CXX
IMPORTED_LOCATION %Project%/leptonica/lib/liblept168.lib)
add_library(libjpeg8c-static-mtdll STATIC IMPORTED)
set_target_properties(
libjpeg8c-static-mtdll
PROPERTIES LINKER_LANGUAGE CXX
IMPORTED_LOCATION %Project%/leptonica/lib/libjpeg8c-static-mtdll.lib)
link_directories(leptonica/lib)
include_directories(leptonica/include)
include_directories(leptonica/include/leptonica)
add_executable(Project "${SOURCE_FILES}")
target_link_libraries(Project liblept168 libjpeg8c-static-mtdll)
What is wrong?