通过cmake FetchContent编译restbed(openssl errs DEPRECATEDIN_1_2_0)?

问题描述 投票:0回答:1

我在 Raspbian Stretch 上有这个设置:

pi@raspberry:~/rtest $ tree /home/pi/rtest/
/home/pi/rtest/
├── build
├── CMakeLists.txt
└── main.cpp

1 directory, 2 files
pi@raspberry:~/rtest $ g++ --version | head -1
g++ (Raspbian 6.3.0-18+rpi1+deb9u1) 6.3.0 20170516

这些文件是这些:

CMakeLists.txt
set(restbed_BUILD_SSL OFF)
是我的猜测,基于运行https示例时遇到问题·问题#470·Corvusoft/restbedhttps://discourse.cmake.org/t/what-在获取内容/268之前设置项目选项的正确方法是):

cmake_minimum_required(VERSION 3.14)

SET(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)

set(FETCHCONTENT_QUIET FALSE)
include(FetchContent)


FetchContent_Declare(
  restbed
  GIT_REPOSITORY https://github.com/Corvusoft/restbed
  GIT_PROGRESS   TRUE
  GIT_TAG        0c99284 # Oct 3, 2022, latest in Jan 2024
)
set(restbed_BUILD_SSL OFF)
set(restbed_BUILD_TESTS OFF)
FetchContent_MakeAvailable(restbed)

project(rtest C CXX ASM)
set(${PROJECT_NAME}_sources
  main.cpp
)

add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_sources})

target_include_directories(${PROJECT_NAME} PUBLIC
  ${restbed_SOURCE_DIR}/source
)

...和

main.cpp

#include <restbed>

int main(void) {
  return 0;
}

然后我这样做:

pi@raspberry:~/rtest $ cd ~/rtest/build
pi@raspberry:~/rtest/build $ ~/src/cmake-3.28.1/bin/cmake ../ -DCMAKE_BUILD_TYPE=Debug
-- Populating restbed
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/pi/rtest/build/_deps/restbed-subbuild
[ 11%] Creating directories for 'restbed-populate'
[ 22%] Performing download step (git clone) for 'restbed-populate'
Cloning into 'restbed-src'...
remote: Enumerating objects: 14304, done.
remote: Counting objects: 100% (239/239), done.
remote: Compressing objects: 100% (131/131), done.
remote: Total 14304 (delta 111), reused 186 (delta 86), pack-reused 14065
Receiving objects: 100% (14304/14304), 4.00 MiB | 5.48 MiB/s, done.
Resolving deltas: 100% (9161/9161), done.
HEAD is now at 0c99284... Merge pull request #517 from voldien/asio-target-include
Submodule 'dependency/asio' (https://github.com/corvusoft/asio-dependency) registered for path 'dependency/asio'
Submodule 'dependency/catch' (https://github.com/corvusoft/catch-dependency) registered for path 'dependency/catch'
Submodule 'dependency/openssl' (https://github.com/corvusoft/openssl-dependency) registered for path 'dependency/openssl'
Cloning into '/home/pi/rtest/build/_deps/restbed-src/dependency/asio'...
Cloning into '/home/pi/rtest/build/_deps/restbed-src/dependency/catch'...
Cloning into '/home/pi/rtest/build/_deps/restbed-src/dependency/openssl'...
Submodule path 'dependency/asio': checked out 'a4d820dd69b37fb8daee275d20eb162054453414'
Submodule path 'dependency/catch': checked out 'd10b9bd02e098476670f5eb0527d2c7281476e8a'
Submodule path 'dependency/openssl': checked out 'fd78df59b0f656aefe96e39533130454aa957c00'
Submodule 'boringssl' (https://boringssl.googlesource.com/boringssl) registered for path 'dependency/openssl/boringssl'
Submodule 'krb5' (https://github.com/krb5/krb5) registered for path 'dependency/openssl/krb5'
Submodule 'pyca.cryptography' (https://github.com/pyca/cryptography.git) registered for path 'dependency/openssl/pyca-cryptography'
Cloning into '/home/pi/rtest/build/_deps/restbed-src/dependency/openssl/boringssl'...
Cloning into '/home/pi/rtest/build/_deps/restbed-src/dependency/openssl/krb5'...
Cloning into '/home/pi/rtest/build/_deps/restbed-src/dependency/openssl/pyca-cryptography'...
Submodule path 'dependency/openssl/boringssl': checked out '2070f8ad9151dc8f3a73bffaa146b5e6937a583f'
Submodule path 'dependency/openssl/krb5': checked out '890ca2f401924cdcb88f493950b04700bbe52db3'
Submodule path 'dependency/openssl/pyca-cryptography': checked out '09403100de2f6f1cdd0d484dcb8e620f1c335c8f'
[ 33%] Performing update step for 'restbed-populate'
[ 44%] No patch step for 'restbed-populate'
[ 55%] No configure step for 'restbed-populate'
[ 66%] No build step for 'restbed-populate'
[ 77%] No install step for 'restbed-populate'
[ 88%] No test step for 'restbed-populate'
[100%] Completed 'restbed-populate'
[100%] Built target restbed-populate
CMake Deprecation Warning at build/_deps/restbed-src/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The CXX compiler identification is GNU 6.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done

##############################################################
#                                                            #
#  Copyright 2013-2020, Corvusoft Ltd, All Rights Reserved.  #
#                                                            #
#  Restbed is dual-licensed requiring commerical entities    #
#  to acquire a Corvusoft Permissive License, Contact        #
#  [email protected] for details.                        #
#                                                            #
##############################################################

-- Found ASIO include at: /home/pi/rtest/build/_deps/restbed-src/dependency/asio/asio/include
-- Found OpenSSL include at: /home/pi/rtest/build/_deps/restbed-src/dependency/openssl/include
-- Found OpenSSL library at: /usr/lib/arm-linux-gnueabihf/libssl.a
-- Found OpenSSL library at: /usr/lib/arm-linux-gnueabihf/libssl.so
-- Found Crypto library at: /usr/lib/arm-linux-gnueabihf/libcrypto.a
-- Found Crypto library at: /usr/lib/arm-linux-gnueabihf/libcrypto.so
-- Found catch: /home/pi/rtest/build/_deps/restbed-src/dependency/catch/single_include/catch2
-- The C compiler identification is GNU 6.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Deprecation Warning at build/_deps/restbed-src/test/unit/CMakeLists.txt:3 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at build/_deps/restbed-src/test/feature/CMakeLists.txt:3 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at build/_deps/restbed-src/test/regression/CMakeLists.txt:3 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at build/_deps/restbed-src/test/integration/CMakeLists.txt:3 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Configuring done (280.8s)
-- Generating done (1.1s)
-- Build files have been written to: /home/pi/rtest/build

因此,FetchContent 提取了 openssl 及其依赖项,尽管出现警告,

cmake
步骤还是完成了。

现在,如果我运行

make

pi@raspberry:~/rtest/build $ make
[  0%] Building CXX object CMakeFiles/rtest.dir/main.cpp.o
In file included from /home/pi/rtest/build/_deps/restbed-src/source/restbed:2:0,
                 from /home/pi/rtest/main.cpp:1:
/home/pi/rtest/build/_deps/restbed-src/source/corvusoft/restbed/http.hpp:109:44: warning: ‘Http’ is deprecated [-Wdeprecated-declarations]
             Http( const Http& original ) = delete;
                                            ^~~~~~
/home/pi/rtest/build/_deps/restbed-src/source/corvusoft/restbed/http.hpp:118:53: warning: ‘Http’ is deprecated: HTTP client is deprecated; we will release a complimentary client framework at a future date. [-Wdeprecated-declarations]
             Http& operator =( const Http& value ) = delete;
                                                     ^~~~~~
In file included from /home/pi/rtest/build/_deps/restbed-src/source/restbed:2:0,
                 from /home/pi/rtest/main.cpp:1:
/home/pi/rtest/build/_deps/restbed-src/source/corvusoft/restbed/http.hpp:46:131: note: declared here
 PRECATED("HTTP client is deprecated; we will release a complimentary client framework at a future date.") HTTP_EXPORT Http
                                                                                                                       ^~~~
In file included from /home/pi/rtest/build/_deps/restbed-src/source/restbed:2:0,
                 from /home/pi/rtest/main.cpp:1:
/home/pi/rtest/build/_deps/restbed-src/source/corvusoft/restbed/http.hpp:118:53: warning: ‘Http’ is deprecated [-Wdeprecated-declarations]
             Http& operator =( const Http& value ) = delete;
                                                     ^~~~~~
[  1%] Linking CXX executable rtest
[  1%] Built target rtest
[  2%] Building CXX object _deps/restbed-build/CMakeFiles/restbed-static.dir/source/corvusoft/restbed/detail/http_impl.cpp.o
In file included from /home/pi/rtest/build/_deps/restbed-src/dependency/openssl/include/openssl/x509.h:22:0,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/openssl/include/openssl/ssl.h:20,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/asio/asio/include/asio/ssl/detail/openssl_types.hpp:24,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/asio/asio/include/asio/ssl/context_base.hpp:19,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/asio/asio/include/asio/ssl/context.hpp:23,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/asio/asio/include/asio/ssl.hpp:18,
                 from /home/pi/rtest/build/_deps/restbed-src/source/corvusoft/restbed/detail/socket_impl.hpp:29,
                 from /home/pi/rtest/build/_deps/restbed-src/source/corvusoft/restbed/detail/http_impl.cpp:21:
/home/pi/rtest/build/_deps/restbed-src/dependency/openssl/include/openssl/ec.h:274:1: error: expected constructor, destructor, or type conversion before ‘DEPRECATEDIN_1_2_0’
 DEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,
 ^~~~~~~~~~~~~~~~~~
/home/pi/rtest/build/_deps/restbed-src/dependency/openssl/include/openssl/ec.h:543:1: error: expected constructor, destructor, or type conversion before ‘DEPRECATEDIN_1_2_0’
 DEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
 ^~~~~~~~~~~~~~~~~~
/home/pi/rtest/build/_deps/restbed-src/dependency/openssl/include/openssl/ec.h:585:1: error: expected constructor, destructor, or type conversion before ‘DEPRECATEDIN_1_2_0’
 DEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,
 ^~~~~~~~~~~~~~~~~~
In file included from /home/pi/rtest/build/_deps/restbed-src/dependency/openssl/include/openssl/x509.h:26:0,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/openssl/include/openssl/ssl.h:20,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/asio/asio/include/asio/ssl/detail/openssl_types.hpp:24,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/asio/asio/include/asio/ssl/context_base.hpp:19,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/asio/asio/include/asio/ssl/context.hpp:23,
                 from /home/pi/rtest/build/_deps/restbed-src/dependency/asio/asio/include/asio/ssl.hpp:18,
                 from /home/pi/rtest/build/_deps/restbed-src/source/corvusoft/restbed/detail/socket_impl.hpp:29,
                 from /home/pi/rtest/build/_deps/restbed-src/source/corvusoft/restbed/detail/http_impl.cpp:21:
/home/pi/rtest/build/_deps/restbed-src/dependency/openssl/include/openssl/dsa.h:103:1: error: expected constructor, destructor, or type conversion before ‘int’
 int DSA_sign(int type, const unsigned char *dgst, int dlen,
 ^~~
_deps/restbed-build/CMakeFiles/restbed-static.dir/build.make:75: recipe for target '_deps/restbed-build/CMakeFiles/restbed-static.dir/source/corvusoft/restbed/detail/http_impl.cpp.o' failed
make[2]: *** [_deps/restbed-build/CMakeFiles/restbed-static.dir/source/corvusoft/restbed/detail/http_impl.cpp.o] Error 1
CMakeFiles/Makefile2:422: recipe for target '_deps/restbed-build/CMakeFiles/restbed-static.dir/all' failed
make[1]: *** [_deps/restbed-build/CMakeFiles/restbed-static.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

因此,尽管有警告,我的可执行文件仍然可以编译 - 但随后,构建过程想要构建

_deps/restbed-build/CMakeFiles/restbed-static.dir/source/corvusoft/restbed/detail/http_impl.cpp.o
(可能是构建一个库?),然后它崩溃了
error: expected constructor, destructor, or type conversion before ‘DEPRECATEDIN_1_2_0’

我已经看到 DEPRECATEDIN_1_2_0() 太急切了·问题#6814·openssl/openssl,但我真的不知道我可以/应该做什么来摆脱错误。

我想,最简单的方法就是在没有 SSL 的情况下进行编译 - 但是这个

restbed/detail/http_impl.cpp.o
明确包含 SSL 内容,即使名称“http_impl”暗示没有 SSL?所以我不确定我的
set(restbed_BUILD_SSL OFF)
是否会在那里产生影响......

那么在这种情况下我可以从 CMake 做些什么来让 Restbed 和/或 openssl 进行编译呢?我现在可以没有 https (openssl 部分),但我真的不知道如何在 CMakeLists.txt 中指定它......

cmake raspberry-pi openssl restbed
1个回答
0
投票

好吧,得到了一些东西 - 对我来说有点令人惊讶,我需要做的就是在我的主

restbed
调用上设置用于
cmake
的 CMake 变量,即:

pi@raspberry:~/rtest/build $ ~/src/cmake-3.28.1/bin/cmake ../ -DBUILD_SSL=NO -DBUILD_TESTS=NO -DCMAKE_BUILD_TYPE=Debug

...然后它们以某种方式传播到休息床,并且

restbed/detail/http_impl.cpp.o
编译时不会触发 OpenSSL 错误。

我可能还应该使用缓存的 CMake 变量 - 但现在没有时间测试......

© www.soinside.com 2019 - 2024. All rights reserved.