我在MAC Mojave上安装了openssl1.1.1d,并在.bash_profile中添加了以下内容:
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export LDflaGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPflaGS="-I/usr/local/opt/openssl@1.1/include"
我一直试图让此代码在CLION上编译,但我一直收到错误消息。
cmake_minimum_required(VERSION 3.15)
project(untitled3 C)
SET (CMAKE_SHARED_LINKER_flaGS ${CMAKE_SHARED_LINKER_flaGS_INIT} $ENV{LDflaGS})
set(CMAKE_C_STANDARD 99)
set(/usr/local/opt/openssl@1.1/bin/openssl)
include_directories(${I})
link_libraries(ssl)
link_libraries(crypto)
set(SOURCE_FILES mywebsock.c)
add_executable(untitled3 mywebsock.c)
错误消息:
fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h> 1 error generated.
我尝试像这样在终端上进行编译:
gcc -Wall -o mywebsock mywebsock.c -lssl -lcrypto -pthread
我收到此错误。
Undefined symbols for architecture x86_64:
"_OPENSSL_init_ssl",referenced from:
_init_openssl in mywebsock -8aaca3.o
ld: symbol(s) not found for architecture x86_64
我认为这是因为我弄错了链接。拜托,有人可以帮我吗?我整夜都在努力解决这个问题。我已经安装并重新安装了openssl。我检查了几篇文章,但似乎无法正确解决。