sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.64k stars 351 forks source link

fatal error: sw/redis++/redis++.h: No such file or directory #335

Closed HuangLianghong closed 2 years ago

HuangLianghong commented 2 years ago

I install redis++ and hiredis at non-default location(e.g. /home/liangzhigao/huanglianghong/redis-plus-plus-lib/), and I want to link the static library in bazel, so I add linkopts as below:

cc_library(
  name = "memory_store",
  srcs = glob([
    "memory_store/*.cpp",
  ]),
  hdrs = glob([
    "memory_store/*.hpp",
  ]),
  deps = [
    "@com_github_google_glog//:glog",
  ],
  linkopts = [
    "-l:/home/liangzhigao/huanglianghong/redis-plus-plus-lib/lib/libredis++.a",
    "-l:/home/liangzhigao/huanglianghong/hiredis-lib/lib/libhiredis.a -pthread",
  ],

But while runing the Build file, error occur:

INFO: Analyzed target //cpp:reas (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/liangzhigao/huanglianghong/reas/cpp/BUILD:15:11: Compiling cpp/memory_store/redis.cpp failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -I/home/liangzhigao/huanglianghong/reas/cython -MD -MF ... (remaining 28 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
cpp/memory_store/redis.cpp:14:10: fatal error: sw/redis++/redis++.h: No such file or directory
 #include <sw/redis++/redis++.h>
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Target //cpp:reas failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.485s, Critical Path: 0.25s
INFO: 7 processes: 7 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

How can I solve this problem?

HuangLianghong commented 2 years ago

I have tried to specify 'hiredis' and 'redis++' include path as below:

cc_library(
  name = "memory_store",
  srcs = glob([
    "memory_store/*.cpp",
  ]),
  hdrs = glob([
    "memory_store/*.hpp",
  ]),
  deps = [
    "@com_github_google_glog//:glog",
  ],
  linkopts = [
    "-l:/home/liangzhigao/huanglianghong/redis-plus-plus-lib/lib/libredis++.a",
    "-l:/home/liangzhigao/huanglianghong/hiredis-lib/lib/libhiredis.a -pthread",
  ],
  copts = [
    "-I/home/liangzhigao/huanglianghong/redis-plus-plus-lib/include",
    "-I/home/liangzhigao/huanglianghong/hiredis-lib/include/",
  ],

)

but another error occur:

ERROR: /home/liangzhigao/huanglianghong/reas/cpp/BUILD:15:11: Compiling cpp/memory_store/memory_store.cpp failed: The include path '/home/liangzhigao/huanglianghong/redis-plus-plus-lib/include' references a path outside of the execution root.
Target //cpp:reas failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.389s, Critical Path: 0.11s
INFO: 4 processes: 4 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
sewenew commented 2 years ago

This looks like a Bazel question. Sorry but I'm not familiar with Bazel. You might need to seek help from a Bazel expert.

Regards