g++ 编译错误信息:/usr/bin/ld: 找不到-lssl

g++ compiling error message: /usr/bin/ld: cannot find -lssl

我按照 tutorial 使用 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.

如何解决这个错误?

如果你想link反对OpenSSL,你需要安装OpenSSL的开发包,像这样:

apt install libssl-dev

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