Connor
Connor

Reputation: 675

Hiredis library not loaded/image not found

I am working on a c++ project using cmake that uses hiredis. The CMake and compilation process do not give any errors. However, when I try to execute my project (from the terminal or from the IDE I'm using [CLion], I get the following error:

dyld: Library not loaded: libhiredis.0.13.dylib

Referenced from: /Users/connorriley/CLionProjects/DispatchingOptimization/bin/dispatch Reason: image not found

I'm not sure why my project is looking for libhiredis.0.13.dylib because the only hiredis library file I have is libhiredis.dylib.

My project file structure is the following:

. 
+-- bin
|   +-- dispatch (my executable)
+-- lib
|   +-- hiredis
|   |   +-- libhiredis.dylib
|   +-- otherlibs
+-- src
|   +-- source code/subfolders with source code

additional info:

Upvotes: 0

Views: 769

Answers (2)

Connor
Connor

Reputation: 675

I fixed my issue, it was that I went into my hiredis directory and typed:

make

but didn't follow that with

make install

Therefore, the file that my code was looking for was not in my /usr/local/lib

Upvotes: 0

mshrbkv
mshrbkv

Reputation: 309

Looks like your DYLD_LIBRARY_PATH is not set correctly. You can get more information by setting DYLD_PRINT_LIBRARIES and/or some other environment variables mentioned here

But probably you just need to add your hiredis directory to CMAKE_LIBRARY_PATH like this: set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${PROJECT_SOURCE_DIR}/lib/hiredis)

Upvotes: 0

Related Questions