HowardHinnant / date

A date and time library based on the C++11/14/17 <chrono> header
Other
3.14k stars 675 forks source link

How to use date/tz.h properly #797

Closed superdiaodiao closed 1 year ago

superdiaodiao commented 1 year ago

If I can successfully run the command: g++ /root/test/date_tz.cpp -o /root/test/date_tz.o -L /root/vcpkg/installed/x64-linux/lib -ldate-tz && /root/test/date_tz.o

then I start a new project and built the date library like this:

build_date() {
    check_if_source_exist $DATE_SOURCE
    cd $TP_SOURCE_DIR/$DATE_SOURCE

    mkdir build
    cd build
    $CMAKE_CMD ..
    make -j$PARALLEL
    make install DESTDIR=${TP_INSTALL_DIR}
}

and set cmakelists.txt like:

add_library(date STATIC IMPORTED)
set_target_properties(date PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/lib/libdate-tz.a)

but why the error said this?

fatal error: date/tz.h: No such file or directory
   20 | #include "date/tz.h"
      |          ^~~~~~~~~~~
compilation terminated.
HowardHinnant commented 1 year ago

I'm afraid I know nothing about make and it was a mistake for me to let people put make files on this repository.

Here are the installation/build instructions I recommend: https://howardhinnant.github.io/date/tz.html#Installation

superdiaodiao commented 1 year ago

OK, thanks for the guild.

superdiaodiao commented 1 year ago

Here are the installation/build instructions I recommend: https://howardhinnant.github.io/date/tz.html#Installation

The build step can be correct, but after building, this cmakelists.txt setting still not works,

add_library(date STATIC IMPORTED)
set_target_properties(date PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/lib/libdate-tz.a)

it seems that the guild you gave and other docs don't help.

superdiaodiao commented 1 year ago

I'm afraid I know nothing about make and it was a mistake for me to let people put make files on this repository.

Here are the installation/build instructions I recommend: https://howardhinnant.github.io/date/tz.html#Installation

Finally, it turns out that my project wasn't set right and the problem mentioned above was solved. Thank you so much.