在Ubuntu 16.04上使用OPENSSL生成C ++问题

时间:2019-01-24 07:58:17

标签: c++ cmake openssl linker

我正在尝试使用openssl库编译一个简单的C ++程序。我使用cmake构建主文件,但出现以下错误。

kafka-console-producer.sh

我的CMakeLists.txt是:

[100%] Building CXX object CMakeFiles/main.dir/main.o
Linking CXX executable main
CMakeFiles/main.dir/main.o: In function `testClass::testClass(int)':
main.cpp:(.text._ZN9testClassC2Ei[_ZN9testClassC5Ei]+0x26): undefined reference to `BN_new'
collect2: error: ld returned 1 exit status
CMakeFiles/main.dir/build.make:83: recipe for target 'main' failed
make[2]: * [main] Error 1
CMakeFiles/Makefile2:57: recipe for target 'CMakeFiles/main.dir/all' failed
make[1]: * [CMakeFiles/main.dir/all] Error 2
Makefile:69: recipe for target 'all' failed
make: * [all] Error 2

我的main.cpp是:

cmake_minimum_required (VERSION 3.0)
project (Hello)
ET(GCC_COVERAGE_COMPILE_FLAGS "-fpermissive -std=c++11 -I /usr/include/openssl/ -lcrypto")
SET(GCC_COVERAGE_LINK_FLAGS    "")
SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
SET( CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}" )
find_library (CRYPTO_LIBRARY crypto)
add_executable(main main.cpp)

0 个答案:

没有答案