我正在尝试使用cmake
在ubuntu 20.04(gcc,g++ version 9.4.0)上安装realm cpp sdk,如下文档所示
我从SDK名称旁边的page顶部获得了GIT_TAG
,并在我的CMakeList.txt
上使用它
cmake_minimum_required(VERSION 3.15)
project(MyRealmCppProject)
set(CMAKE_CXX_STANDARD 17)
Include(FetchContent)
set(REALM_USE_SYSTEM_OPENSSL ON)
FetchContent_Declare(
cpprealm
GIT_REPOSITORY https://github.com/realm/realm-cpp.git
GIT_TAG 5dab867db1e3ed63b1c4aba611991724d16cd0ce
)
FetchContent_MakeAvailable(cpprealm)
add_executable(myApp main.cpp)
target_link_libraries(myApp PRIVATE cpprealm)
看起来cmake
运行得很好,但是最后一步make
导致错误。
...
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
我想问题可能是来自sdk本身,但我不确定。如何成功安装和构建Realm C++ SDK?
1条答案
按热度按时间e5nszbig1#
根据我从我做的github issue得到的信息,据说任何低于GCC 11和Ubuntu 22.04的东西都还没有测试过。由于我使用的是GCC 9.4.0和Ubuntu 20.04,可能会有兼容性问题(我认为Starball说的是对的)。通过使用
cmake -DREALM_CPP_NO_TESTS=1 ..
阻止SDK执行测试应该可以让它成功构建。以下代码在生成后成功运行。
由于我设法以这种方式成功地构建了SDK,我认为这个问题已经得到了回答。
然而,我仍然有点担心,因为跳过测试可能无法解决其潜在的问题。