[CXX-2738] libmongoc and libbson don't get installed (in program Files/mongo-c-driver) Created: 27/Aug/23  Updated: 27/Oct/23  Resolved: 05/Sep/23

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Daniel Korkotyan Assignee: Kevin Albertson
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File PS_cmake_build_and_install_output.txt     Text File cmake_build_and_install_after_DENABLE_ZSTD=OFF_output.txt     Text File cmake_build_and_install_output.txt     Text File cmake_generate_build_files_output.txt     Text File cmake_generate_build_files_with_DENABLE_ZSTD=OFF_output.txt    

 Description   

Build fails in windows 10 (19045.3324).

Running 'cmake --build . --config RelWithDebInfo --target install' results in:

  1. Multiple error of the same cause: mongoc-compression.c(32,10): fatal  error C1083: Cannot open include file: 'zstd.h': No such file or directory [C:\repos\mongo-c-driver-1.24.3\cmake-build\src\libmongoc\mongoc_shared.vcxproj]
  2. Build is not present in the dir of CMAKE_INSTALL_PREFIX ('C:/Program Files/mongo-c-driver').


 Comments   
Comment by Kevin Albertson [ 05/Sep/23 ]

Glad to hear that worked.

I attached the output of the build target command as PS_cmake_build_and_install_output.txt. It says at the end of the output:

B A T C H R E C U R S I O N exceeds STACK limits
Recursion Count=289, Stack Usage=90 percent

B A T C H PROCESSING IS A B O R T E D ******
I think the execution worked, but I'll test and make sure of it further first thing tomorrow.

That may be resolved with CDRIVER-4520.

Comment by Daniel Korkotyan [ 04/Sep/23 ]

Hi Kevin,

Sorry for the late response mate.

Running the commands from PS worked, the mongo-c-driver was created in program files, thank you. Can't say I understand why running the commands from mingw makes this kind of trouble. I'll try to read more about it.

I followed the guide from here [Build environment on Windows with MinGW-W64 and MSYS2|Installing the MongoDB C Driver (libmongoc) and BSON library (libbson) — libmongoc 1.24.3]

Now, I clearly see on the most recently published guide ([Getting Started with MongoDB and C++|[Getting Started with MongoDB and C++ | MongoDB|https://www.mongodb.com/developer/products/mongodb/getting-started-mongodb-cpp/]]) that it says to run these commands from PS or command line.

I attached the output of the build target command as PS_cmake_build_and_install_output.txt. It says at the end of the output:

            •  B A T C H   R E C U R S I O N  exceeds STACK limits

 Recursion Count=289, Stack Usage=90 percent

            •       B A T C H   PROCESSING IS   A B O R T E D      ******

I think the execution worked, but I'll test and make sure of it further first thing tomorrow.

Kevin, thank you very much for your time and patience.

Comment by Kevin Albertson [ 30/Aug/23 ]

Cannot open include file: 'zstd.h': No such file or directory

cmake_generate_build_files_output.txt suggests pkg-config from msys2 is found:

-- Found PkgConfig: C:/msys64/mingw64/bin/pkg-config.exe (found version "2.0.2")

I expect this is caused by using the mingw shell with the "Visual Studio 17 2022" generator. The C driver uses pkg-config to locate a system install of zstd.
In the mingw shell, pkg-config does not include the /c/msys64/include directory in the output by default:

#  pkg-config --libs --cflags libzstd
-lzstd

I expect that is the cause of the "Cannot open include file" error. Forcing include of the mingw headers with the MSVC compiler results in errors. I expect mingw headers are not intended to be built with MSVC.

I suggest use Powershell or command prompt to build with the "Visual Studio 17 2022" generator. The following succeeded for me:

Installed CMake using the "Windows x64 Installer" from https://cmake.org/download/ to the path "C:\cmake".
Opened Powershell and navigated to mongo-c-driver directory.
Ran the following commands:

C:\cmake\bin\cmake.exe -G "Visual Studio 17 2022" -A x64 -S "." -B "cmake-build"
C:\cmake\bin\cmake.exe --build "cmake-build" --target install

Comment by Kevin Albertson [ 29/Aug/23 ]

Thank you for the additional information. That may help to diagnose the issue.

I tried also running the build generate with the DENABLE_ZSTD=OFF flag, but although the output seemed promising, it resulted in errors when running the build and install cmake command.

The cmake_build_and_install_after_DENABLE_ZSTD=OFF_output.txt output suggests this may be due to needed privileges:

  -- Install configuration: "RelWithDebInfo"
  CMake Error at cmake_install.cmake:36 (file):
    file cannot create directory: C:/Program Files/mongo-c-driver/bin.  Maybe
    need administrative privileges.

Setting -DCMAKE_INSTALL_PREFIX to a different install path may help to work around.

Comment by Daniel Korkotyan [ 28/Aug/23 ]

Hi Kevin,

Sure, I've included the outputs (as attached files) of the following commands, thank you for the response.

cmake_generate_build_files_output.txt - cmake -G "Visual Studio 17 2022" -A x64 -S "C:\Repos\mongo-c-driver-1.24.3" -B "C:\Repos\mongo-c-driver-1.24.3\cmake-build"

cmake_build_and_install_output.txt - cmake --build . --config RelWithDebInfo --target install

 

I tried also running the build generate with the DENABLE_ZSTD=OFF flag, but although the output seemed promising, it resulted in errors when running the build and install cmake command. The outputs are included as well.

cmake_generate_build_files_with_DENABLE_ZSTD=OFF_output.txt

cmake_build_and_install_after_DENABLE_ZSTD=OFF_output.txt

Comment by Kevin Albertson [ 28/Aug/23 ]

Hi korkotyan@gmail.com , thank you for the report.

Can you include the full output of the CMake configure step. There may be output related to zstd that can help to diagnose the issue. Running cmake results in output indicating where zstd is found:

 
-- Searching for compression library zstd
-- Found PkgConfig: /opt/homebrew/bin/pkg-config (found version "0.29.2") 
-- Checking for module 'libzstd'
--   Found libzstd, version 1.5.5
--   Found zstd version 1.5.5 in /opt/homebrew/Cellar/zstd/1.5.5/include

As a workaround: if the zstd network compressor is not needed, consider passing -DENABLE_ZSTD=OFF to the cmake configure step to disable building with zstd.

Comment by PM Bot [ 27/Aug/23 ]

Hi korkotyan@gmail.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 22:06:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.