Nordix / hiredis-cluster

C client library for Valkey/Redis Cluster. This project is used and sponsored by Ericsson. It is a fork of the now unmaintained hiredis-vip.
BSD 3-Clause "New" or "Revised" License
86 stars 42 forks source link

symbol lookup error: /usr/local/lib/libhiredis_cluster.so.0.13: undefined symbol: hiredisAllocFns #215

Closed risaruno closed 4 months ago

risaruno commented 4 months ago

I couldn't find anybody having this problem. I'm also new in C programming.

So I will just explain what I did.

  1. I download the hiredis_cluster tar file, and extracted it.
  2. Just as the Readme told me, I make build directory and installing it using cmake.
  3. My c files compiled perfectly fine. But, when I run the file, the error told me that I need libhiredis_cluster.so.0.13 under /usr/local/lib folder. Which the installation didn't generate.

    error while loading shared libraries: libhiredis_cluster.so.0.13: cannot open shared object file: No such file or directory

  4. I go back to hiredis_cluster folder and use make command and make install command to install the file that I mentioned.
  5. I compile my program again and now this what is coming.

    symbol lookup error: /usr/local/lib/libhiredis_cluster.so.0.13: undefined symbol: hiredisAllocFns

Is there anybody know what is happening here?

Thank you.

bjosv commented 4 months ago
  1. My c files compiled perfectly fine. But, when I run the file, the error told me that I need libhiredis_cluster.so.0.13 under /usr/local/lib folder. Which the installation didn't generate.

Did you install the built hiredis-cluster libraries using make install? (as root/with sudo). During this step the build will printout where the libraries are placed, is it using the expected destination? Example:

> sudo make install
..
Install the project...
-- Install configuration: "Debug"
-- Installing: /usr/local/lib/libhiredis_cluster.so.0.13
...

See this example how to change the install directory.

  1. I compile my program again and now this what is coming.

    symbol lookup error: /usr/local/lib/libhiredis_cluster.so.0.13: undefined symbol: hiredisAllocFns

When building using the provided Makefile (i.e. not using CMake) the dependency hiredis is taken from the system and you probably have a hiredis version before 1.0, which lacks hiredisAllocFns. hiredis-cluster require hiredis >= 1.0.

You need to upgrade your hiredis, or you can build and install hiredis yourself and maybe this example can give some help?

risaruno commented 4 months ago

Thanks for your answer. But, I still have some questions in minds.

Did you install the built hiredis-cluster libraries using make install? (as root/with sudo). During this step the build will printout where the libraries are placed, is it using the expected destination?

Yes, I did this step in number 4. But I'm also wondering. Why do I still need to install it using make install even after I did the installation using build folder? What is the difference?

When building using the provided Makefile (i.e. not using CMake) the dependency hiredis is taken from the system and you probably have a hiredis version before 1.0, which lacks hiredisAllocFns. hiredis-cluster require hiredis >= 1.0.

Yes, I did install hiredis with a lower version in the default directory before. But, If I install the hiredis_cluster using the build folder, Isn't will overwrite the previous version?

Pardon me, if my question is too basic.

bjosv commented 4 months ago

Yes, I did this step in number 4. But I'm also wondering. Why do I still need to install it using make install even after I did the installation using build folder? What is the difference?

There are two ways to build hiredis-cluster, either with CMake which generates a Makefile, or with a provided Makefile directly (see Readme). You only need to either build and install from the created CMake build directory, or from the repo root using the provided Makefile.

The CMake build should download the required dependency hiredis, while the provided Makefile will use the system installed hiredis installation.

Yes, I did install hiredis with a lower version in the default directory before. But, If I install the hiredis_cluster using the build folder, Isn't will overwrite the previous version?

It should overwrite existing libraries if the install-path is the same, but it might not be the case here.

risaruno commented 4 months ago

I think I made a mistake while compiling my program. I should've also insert the -lhiredis and not only the -lhiredis-cluster library. Thank you for your explanation. ^~