1

I'm just beginning to learn more about Linux as I'm using Ubuntu.

I'm trying to install a header-only library called "date.h" from here

An excerpt from the github states that this is a header-only library

"date.h" is a header-only library which builds upon <chrono>. It adds some new duration types, and new time_point types. It also adds "field" types such as year_month_day which is a struct {year, month, day}. And it provides convenient means to convert between the "field" types and the time_point types.

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install date

I followed the above instruction and now I have /home/username/vcpkg/ with many other directories underneath it.

I navigated to /home/username/vcpkg/installed/x64-linux/include/date and found date.h and tz.h, which I were looking for.

I'm trying to use them in a C++ project but I'm not sure how to tell the compiler where to find the header files. Should I cut/copy paste /date directory into /user/include/c++/9, or /usr/local/include, or /usr/local/include/x86_64-linux-gnu? or should I do none of those? Am I supposed to define the path to the library in my files/makefile somehow?

Thank you

drescherjm
  • 10,365
  • 5
  • 44
  • 64
  • Ideally you will want to learn how to create native Debian/Ubuntu packages, and prepare an installable package, with that header, that installs this header file. Unfortunately, a complete tutorial for this process is out of scope for stackoverflow.com, but I'm sure you can find plenty of material on the interwebs that explain how to do that. And, it should be a good learning experience. – Sam Varshavchik Feb 02 '20 at 23:30
  • What type of project is this? How do you build it? – Thomas Sablik Feb 02 '20 at 23:50
  • 1
    I just throw header-only libraries directly in the source tree of the project that's using it. Failing that, `/usr/local/include`. – Shawn Feb 03 '20 at 02:04

1 Answers1

0

You just need to pass VCPKG toolchain file to CMake:

cmake -B build -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build 

Please adjust DCMAKE_TOOLCHAIN_FILE to your VCPKG installation path.

If you would like to use VCPKG manifest mode (with file that describes all dependent libraries), just add one more parameter "-DVCPKG_FEATURE_FLAGS=versions":

cmake -B build -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_FEATURE_FLAGS=versions
cmake --build build 
Pavel K.
  • 983
  • 9
  • 21