hiredis icon indicating copy to clipboard operation
hiredis copied to clipboard

hiredis.pc for 0.13 and later version broke the old include style

Open shiluotang opened this issue 5 years ago • 0 comments

The hiredis.pc file generation section:

$(PKGCONFNAME): hiredis.h
    @echo "Generating $@ for pkgconfig..."
    @echo prefix=$(PREFIX) > $@
    @echo exec_prefix=\$${prefix} >> $@
    @echo libdir=$(PREFIX)/$(LIBRARY_PATH) >> $@
    @echo includedir=$(PREFIX)/$(INCLUDE_PATH) >> $@
    @echo >> $@
    @echo Name: hiredis >> $@
    @echo Description: Minimalistic C client library for Redis. >> $@
    @echo Version: $(HIREDIS_MAJOR).$(HIREDIS_MINOR).$(HIREDIS_PATCH) >> $@
    @echo Libs: -L\$${libdir} -lhiredis >> $@
    @echo Cflags: -I\$${includedir} -D_FILE_OFFSET_BITS=64 >> $@

will create something like this:

includedir=/usr/local/include/hiredis

So the users need to include the header file like this:

#include <hiredis.h>

Rather than the old style

#include <hiredis/hiredis.h>

(The old style may be still working only if we install it into the system include path "/usr/include")

When users depend on pkg-config tool to generate cflags for hiredis, this will be a serious problem!

  1. This is in incompatible with the hiredis-dev:0.10 package on debian or centos.
  2. The old style include is definitly not working when the hiredis package is installed into an arbitary path. Users have to use dirty tricks to include different version hiredis header. This is meaningless!

Solution is easy: Just make sure the last part "hiredis" disappear in "includedir", then the problem solved.

shiluotang avatar Nov 21 '18 03:11 shiluotang