CMake - how to add a missing library easily?

1.6k Views Asked by At

I'm trying to install Darknet from here https://github.com/AlexeyAB/darknet using these instructions:

https://github.com/AlexeyAB/darknet#how-to-compile-on-windows-using-cmake

Looked easy enough, I installed all the required pre-requisites...

I get the error "Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR)" with CMake, I had an error like it before for Zlib, which I was able to install using this .bat file https://github.com/horta/zlib.install/blob/master/install.bat

What is the simplest way to include this library called' JPEG' within Cmake's scope of libraries?

1

There are 1 best solutions below

2
On BEST ANSWER

On Windows, the easiest way to manage C++ dependencies, by far, is vcpkg. Follow the directions on their repo to install:

> git clone https://github.com/microsoft/vcpkg
> .\vcpkg\bootstrap-vcpkg.bat

Then install libjpeg as well as any other dependencies:

> .\vcpkg\vcpkg install libjpeg libjpeg-turbo:x64-windows

If you need 32-bit, install libjpeg-turbo:x86-windows additionally (or instead).

Then, when trying to build Darknet, configure CMake with:

> cmake -DCMAKE_TOOLCHAIN_FILE=X:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake ...

On the other hand, vcpkg has a darknet port, so you could just run:

> .\vcpkg\vcpkg install darknet[full]:x64-windows

Doesn't answer the question you asked, but maybe it's what you want, anyway.