OpenSSL Version for Realm C++ SDK

I am installing Realm C++ SDK using cmake.

I am following instructions from https://www.mongodb.com/docs/realm/sdk/cpp/install/#install
so the CMakeList.txt content I use is the same, except for the GIT_TAG where I use the hash from Realm C++ SDK: Realm C++ SDK at the top of the page next to the SDK name, that is 5dab867db1e3ed63b1c4aba611991724d16cd0ce.

However, cmake doesn’t build successfully, which I guess is because of mismatch in OpenSSL version. Realm seems to be using OpenSSL 3.0.8, while my pc is using OpenSSL 1.1.1f.

My question is, is OpenSSL 3.0.8 a strict requirement for Realm?
What should be done to install Realm successfully?

edit: I am using ubuntu 20.04, so the latest openssl package I can get is 1.1.1f-1ubuntu2.19.

Hey @znyi, by default Realm downloads a precompiled OpenSSL binary to build against and it just so happens that the latest available was 3.0.8, but that’s not required. You can force Realm to use whatever version of OpenSSL you have installed on your system by adding set(REALM_USE_SYSTEM_OPENSSL ON) just before the FetchContent_Declare call in your CMakeLists.txt.

Out of curiosity, what’s the exact build error you’re currently getting?

On build, this this what I got:

-- CMake version: 3.16.3
Dependencies: PACKAGE_NAME=realm-core;VERSION=13.9.2;OPENSSL_VERSION=3.0.8;WIN32_ZLIB_VERSION=1.2.13;MDBREALM_TEST_SERVER_TAG=2023-04-13
-- Using linker gold
CMake Error at build/_deps/cpprealm-src/realm-core/CMakeLists.txt:275 (string):
  string sub-command REGEX, mode MATCH needs at least 5 arguments total to
  command.


-- Configuring incomplete, errors occurred!
See also "/home/malacoda/am_offline_db/cloud_db_test/build/CMakeFiles/CMakeOutput.log".
See also "/home/malacoda/am_offline_db/cloud_db_test/build/CMakeFiles/CMakeError.log".

Examining build/_deps/cpprealm-src/realm-core/CMakeLists.txt:275, that is

string(REGEX MATCH "^([0-9]+)\\.([0-9]+)" OPENSSL_VERSION_MAJOR_MINOR ${OPENSSL_VERSION})

so I guess there is something wrong with the OpenSSL version.

However, adding set(REALM_USE_SYSTEM_OPENSSL ON) doesn’t solve this problem. Did I miss something here?

UPDATE: after removing everything and performing cmake and make again (according to official documentations), cmake is done successfully, but make returns error as follows:

...
Scanning dependencies of target cpprealm_exe_tests
[ 90%] Building CXX object _deps/cpprealm-build/CMakeFiles/cpprealm_exe_tests.dir/tests/str_tests.cpp.o
[ 90%] Building CXX object _deps/cpprealm-build/CMakeFiles/cpprealm_exe_tests.dir/tests/list_tests.cpp.o
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp: In lambda function:
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp:331:19: error: use of deleted function ‘realm::notification_token::notification_token(const realm::notification_token&)’
  331 |            return token;
      |                   ^~~~~
In file included from /home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/src/cpprealm/object.hpp:22,
                 from /home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/src/cpprealm/persisted_embedded.hpp:22,
                 from /home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/src/cpprealm/sdk.hpp:29,
                 from /home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/main.hpp:5,
                 from /home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp:1:
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/src/cpprealm/notifications.hpp:39:8: note: ‘realm::notification_token::notification_token(const realm::notification_token&)’ is implicitly declared as deleted because ‘realm::notification_token’ declares a move constructor or move assignment operator
   39 | struct notification_token {
      |        ^~~~~~~~~~~~~~~~~~
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp: In lambda function:
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp:371:19: error: use of deleted function ‘realm::notification_token::notification_token(const realm::notification_token&)’
  371 |            return token;
      |                   ^~~~~
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp: In lambda function:
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp:402:19: error: use of deleted function ‘realm::notification_token::notification_token(const realm::notification_token&)’
  402 |            return token;
      |                   ^~~~~
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp: In function ‘void CATCH2_INTERNAL_TEST_0()’:
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp:445:37: error: cannot convert ‘int’ to ‘const std::variant<std::monostate, long int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, double, std::vector<unsigned char, std::allocator<unsigned char> >, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >, realm::uuid, realm::object_id>&’
  445 |        obj.list_mixed_col.push_back(42);
      |                                     ^~
      |                                     |
      |                                     int
In file included from /home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/src/cpprealm/sdk.hpp:32,
                 from /home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/main.hpp:5,
                 from /home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/tests/list_tests.cpp:1:
/home/malacoda/am_offline_db/cloud_db_test/build/_deps/cpprealm-src/src/cpprealm/persisted_list.hpp:171:33: note:   initializing argument 1 of ‘void realm::persisted<std::vector<Duration>, typename std::enable_if<std::negation<std::disjunction<std::is_same<typename realm::internal::type_info::type_info<ValueType, void>::internal_type, std::optional<realm::internal::bridge::obj_key> >, std::is_same<typename realm::internal::type_info::type_info<ValueType, void>::internal_type, realm::internal::bridge::obj_key>, std::is_same<typename realm::internal::type_info::type_info<ValueType, void>::internal_type, realm::internal::bridge::list>, std::is_same<typename realm::internal::type_info::type_info<ValueType, void>::internal_type, realm::internal::bridge::dictionary> > >::value, void>::type>::push_back(const T&) [with T = std::variant<std::monostate, long int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, double, std::vector<unsigned char, std::allocator<unsigned char> >, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >, realm::uuid, realm::object_id>; typename std::enable_if<std::negation<std::disjunction<std::is_same<typename realm::internal::type_info::type_info<ValueType, void>::internal_type, std::optional<realm::internal::bridge::obj_key> >, std::is_same<typename realm::internal::type_info::type_info<ValueType, void>::internal_type, realm::internal::bridge::obj_key>, std::is_same<typename realm::internal::type_info::type_info<ValueType, void>::internal_type, realm::internal::bridge::list>, std::is_same<typename realm::internal::type_info::type_info<ValueType, void>::internal_type, realm::internal::bridge::dictionary> > >::value, void>::type = void]’
  171 |         void push_back(const T& value)
      |                        ~~~~~~~~~^~~~~
make[2]: *** [_deps/cpprealm-build/CMakeFiles/cpprealm_exe_tests.dir/build.make:76: _deps/cpprealm-build/CMakeFiles/cpprealm_exe_tests.dir/tests/list_tests.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:374: _deps/cpprealm-build/CMakeFiles/cpprealm_exe_tests.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

I believe this is because of the codes in the provided sdk, so I also raised a github issue.

Should I make another topic in mongodb community to address this?