c - 使用 gcc 为 HTTPS(OPENSSL)编译 Socket C 程序时出错
问题描述
我正在 Ubuntu 18 上使用 OpenSSL 包准备一个套接字 C 程序。当我尝试使用以下命令编译程序时:
gcc WinSocketClientSSL.c -o WinSocketClientSSL -lssl
我收到以下错误:
/usr/bin/ld: /tmp/ccfr2z39.o: undefined reference to symbol 'OPENSSL_init_crypto@@OPENSSL_1_1_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libcrypto.so.1.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
我已经尝试使用 target_link_libraries(),因为我的 libssl.a 和 libcrypto.a 文件位于 /usr/lib/x86_64-linux-gnu/ 文件夹中。以下是我的条目:
add_executable(Win_Socket_Client_SSL src/WinSocketClientSSL.c)
target_link_libraries(WinSocketClientSSL /usr/libx86_64-linux-gnu/libssl.a)
target_link_libraries(WinSocketClientSSL /usr/libx86_64-linux-gnu/libcrypto.a)
解决方案
推荐阅读
- java - 构建java kafka-stream应用程序的jar
- reactjs - 如何优化 React Photo Gallery 以加载大图像
- python - Django 部署在共享托管服务器(Hostgator)中
- rx-java - rxjava 最终关闭 Observable 时是否有回调可以接收?
- python - 为什么我需要一个选项卡?
- ruby-on-rails - Rails 5.2 Active Storage 获得文件的永久链接
- filter - 如何将公式变成数组
- powershell - 为写输出创建函数
- javascript - 传递给函数的值不会被复制
- axapta - 将 SQL 转换为 X++