首页 > 解决方案 > g++ 编译错误信息:/usr/bin/ld: 找不到 -lssl

问题描述

我按照教程使用 C++ 连接到 DolphinDB 服务器,并在编译main.cpp时遇到此错误消息:

$ g++ main.cpp -std=c++11 -DLINUX -DLOGGING_LEVEL_2 -O2 -I../include -lDolphinDBAPI -lssl -lpthread -luuid -L../bin -Wl,-rpath ../bin/ -o main
/usr/bin/ld: cannot find -lssl
collect2: error: ld returned 1 exit status

请注意,我的 g++ 版本高于 v6.2:

$ g++ --version
g++ (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

如何解决这个错误?

标签: c++databaseubuntug++dolphindb

解决方案


如果要链接 OpenSSL,则需要安装 OpenSSL 的开发包,如下所示:

apt install libssl-dev

也可以-lssl从链接器命令行中删除 。(如果项目依赖于 OpenSSL,则构建不会走到这一步,因为 OpenSSL 头文件也丢失了。)


推荐阅读