[CXX-2579] Extra Steps Needed to Build on arm64 Created: 27/Sep/22  Updated: 07/Feb/24  Resolved: 28/Mar/23

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

Type: Task Priority: Unknown
Reporter: Steve Silvester Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: buildfest-2022
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CXX-2613 C++ driver fails to build on M1 Mac Closed
Epic Link: CXX-2634
Quarter: FY24Q1

 Description   

When building an application using CXX driver on my M1 mac, I had to repair the executables using the instructions in https://stackoverflow.com/questions/1937232/linking-to-a-dynamic-library-on-a-mac-with-full-path

I am on an macOS Monterrey 12.6 M1 Max. The command I used to build was:

export PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig"
g++ -Wno-deprecated -fsanitize=address,undefined -std=c++17 $(pkg-config --cflags --libs libmongocxx) $(pkg-config --cflags --libs sdl2) -lSDL2_mixer -lSDL2_ttf -o leafie_pong AtlasManager.cpp Main.cpp

The repair code I ran was:

 install_name_tool -change @rpath/libbsoncxx._noabi.dylib $HOME/.local/lib/libbsoncxx._noabi.dylib leafie_pong
  install_name_tool -change @rpath/libmongocxx._noabi.dylib $HOME/.local/lib/libmongocxx._noabi.dylib leafie_pong



 Comments   
Comment by Githook User [ 28/Mar/23 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CXX-2579 use standard directories in main install instructions (#944)

  • fix link rendering on configuration page
  • include `/lib` in CMAKE_INSTALL_RPATH instruction

And explain rationale. This can help a consumer locate libbsoncxx.so if the consumer only links to full path of libmongocxx.so.

  • replace `/opt/` with `$HOME`

To prevent requiring users to have additional permissions.
Installing to `/opt` on macOS requires root permissions.

  • add "Installing to non-standard directories" section to advanced.md
  • add instructions for specifying a custom C driver install
  • use standard install directories in main installation instructions
  • add instructions for fixes to locate shared libraries
  • use <install-dir>, not /usr/local, for uninstall example

Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>

  • exclude `CMAKE_PREFIX_PATH` or `CMAKE_INSTALL_PREFIX` from unrelated examples
  • combine `For Linux and macOS` and `For Windows` sections

The instructions are no longer platform specific.

---------

Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/57e37617421a8cb7210856ca491ce2131d9b4127

Comment by Kevin Albertson [ 19/Mar/23 ]

Other reports referencing "cannot open shared object file" errors related to the C++ driver:

https://www.mongodb.com/community/forums/t/compilation-error-for-the-c-driver-error-while-loading-shared-libraries-libmongocxx-so-noabi-cannot-open-shared-object-file-no-such-file-or-directory/12710
https://www.mongodb.com/community/forums/t/cxx-driver-cannot-find-dependencies/4775
https://stackoverflow.com/questions/51131114/error-while-loading-shared-libraries-libbsoncxx-so-noabi-cannot-open-shared-o

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