[CDRIVER-3599] Library path may not be added when zstd is detected Created: 31/Mar/20  Updated: 05/Feb/24

Status: Backlog
Project: C Driver
Component/s: cmake
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Kevin Albertson Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-3483 Re-enable building with zstd support ... Closed
Epic Link: CDRIVER-4577

 Description   

As was observed with building libmongoc during a C++ driver release with roberto.sanchez, it appears that libzstd may be detected and linked to with -lzstd, without the full path to the library being added.

I observed this on macOS with cmake 1.16.2 when installing via the C++ driver's script:

cd mongo-cxx-driver
./.evergreen/install_c_driver master
...

cmake runs with:

/Applications/Cmake.app/Contents/bin/cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_SHM_COUNTERS=OFF -DENABLE_BSON=ON -DENABLE_TESTS=OFF -DENABLE_EXAMPLES=OFF -DENABLE_STATIC=ON -DENABLE_EXTRA_ALIGNMENT=OFF -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_PREFIX=/Users/kevinalbertson/code/mongo-cxx-driver/../mongoc/ -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF .

And is able to find zstd:

...
-- Searching for compression library zstd
-- Checking for module 'libzstd'
--   Found libzstd, version 1.4.0
--   Found zstd version 1.4.0 in /usr/local/include
...

But linking fails:

ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)



 Comments   
Comment by Edwin Zhou [ 09/Jan/23 ]

I came across this error when building the C driver v1.16.2 on macOS 12.6.2.

[ 37%] Linking C shared library libmongoc-1.0.dylib
ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/libmongoc/libmongoc-1.0.0.0.0.dylib] Error 1
make[1]: *** [src/libmongoc/CMakeFiles/mongoc_shared.dir/all] Error 2
make: *** [all] Error 2

Adding

-DENABLE_ZSTD=OFF 

made it go away.

Generated at Wed Feb 07 21:18:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.