【发布时间】:2022-01-28 13:15:27
【问题描述】:
我是 C 编程新手,我想开始一个项目以用于学习目的。 我正在尝试使用 cygwin 在 Windows 上使用 clion 在 C 中打开一个 ssl 套接字。 对于我一直在使用本教程的代码: https://aticleworld.com/ssl-server-client-using-openssl-in-c/
我已经用这些库安装了 cygwin:make、gdb、gcc-g++、libssl-dev
我在编辑器中没有看到任何编译错误,但我无法运行项目。
当我尝试运行它时,我在链接阶段收到很多 undefined 错误:
undefined reference to `OPENSSL_init_crypto'
undefined reference to `OPENSSL_init_ssl'
undefined reference to `SSL_CTX_new'
还有更多类似的。
所以我将 m cmake 文件更新为如下所示:
cmake_minimum_required(VERSION 3.21)
project(ssl_example C)
set(CMAKE_C_STANDARD 99)
include_directories(/usr/include/openssl/)
link_libraries(openssl)
add_executable(ssl_example main.c)
现在我得到了这个错误-
FAILED: ssl_example.exe
: && /usr/bin/gcc.exe -g -Wl,--enable-auto-import CMakeFiles/ssl_example.dir/main.c.o -o ssl_example.exe -Wl,--out-implib,libssl_example.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lopenssl -lcrypto && :
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lopenssl
collect2: error: ld returned 1 exit status
编辑:
this is how my cmake file looks like:
cmake_minimum_required(VERSION 3.21)
project(ssl_example C)
set(CMAKE_C_STANDARD 99)
include_directories(/usr/include/openssl/)
link_libraries(ssl)
link_libraries(crypto)
link_libraries(openssl)
add_executable(ssl_example main.c)
我仍然遇到同样的错误cannot find -lopenssl
【问题讨论】: