macOS 10.15.5
C++14
OpenSSL 1.1.1
需要依赖于
OpenSSL
,推荐OpenSSL 1.1
及以上版本
安装OpenSSL
brew install openssl
git clone https://gitee.com/mirrors/sogou-cpp-workflow.git
cd sogou-cpp-workflow
mkdir build
cd build
cmake ..
make
sudo make install
如果cmake因为OpenSSL失败: 指定OpenSSL路径
# 查看OpenSSL安装路径
brew link openssl --force
For compilers to find openssl@1.1 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
# 指定OpenSSL路径再cmake
cmake ../ -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1/ -DOPENSSL_LIBRARIES=/usr/local/opt/openssl@1.1/lib
一个简单的Http服务
#include <workflow/WFHttpServer.h>
int main() {
WFHttpServer server([](WFHttpTask *task) {
task->get_resp()->append_output_body("<html>Hello World!</html>");
});
if (server.start(8888) == 0) { // start server on port 8888
getchar(); // press "Enter" to end.
server.stop();
}
return 0;
}
cmake_minimum_required(VERSION 3.17)
project(sogou_demo)
set(CMAKE_CXX_STANDARD 14)
include_directories(/usr/local/include) # Sogou workflow 头文件路径
include_directories(/usr/local/opt/openssl@1.1/include) # openssl头文件路径
set (OPENSSL_CRYPTO_LIBRARY /usr/local/opt/openssl@1.1/lib/libcrypto.dylib) # crypto动态链接库路径
set (OPENSSL_SSL_LIBRARY /usr/local/opt/openssl@1.1/lib/libssl.dylib) # ssl动态链接库路径
LINK_DIRECTORIES(/usr/local/lib/) # openssl静态链接库路径
add_executable(sogou_demo main.cpp) # 主函数
target_link_libraries(sogou_demo workflow ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY}) # workflow: 链接/usr/local/lib下的workflow静态链接库
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有