简体   繁体   English

交叉编译arm cortex-m4的libwebsockets时出现cmake错误

[英]cmake errors when cross-compiling libwebsockets for arm cortex-m4

Let me preface this question: I've spent hours today researching this problem, with many hits on stackoverflow. 让我先说一下这个问题:我今天花了好几个小时研究这个问题,在stackoverflow上有很多命中。 I feel like I'm close, but there's always something in the way. 我觉得我很亲近,但总有一些东西在路上。 I wouldn't be asking if I didn't feel like I've exhausted what Google has to offer. 我不会问我是不是觉得我已经厌倦了谷歌提供的东西了。 I know my target intimately and have cross-compiled many open source packages successfully, however, given that libwebsockets uses cmake, which I'm unfamiliar with, the errors are quite alien to me; 我非常了解我的目标,并成功地交叉编译了许多开源软件包,但是,鉴于libwebsockets使用的是我不熟悉的cmake,错误对我来说非常陌生; I suppose I could pour through cmake documentation, but I doubt I'd find the answer within the timeframe I have. 我想我可以通过cmake文档,但我怀疑我会在时间框架内找到答案。

I'm trying to cross-compile libwebsockets for an ARM-Cortex-M4 platform. 我正在尝试为ARM-Cortex-M4平台交叉编译libwebsockets。 I've followed the instructions from the libwebsockets documentation: 1) create a "build" directory above the libwebsockets source directory. 我按照libwebsockets文档中的说明进行操作:1)在libwebsockets源目录上创建一个“build”目录。 2) From within the build directory, call cmake: 2)在构建目录中,调用cmake:

cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross.cmake

3) I've used their ARM template to create cross.cmake 3)我使用他们的ARM模板来创建cross.cmake

#
# CMake Toolchain file for crosscompiling on ARM.
#
# This can be used when running cmake in the following way:
#  cd build/
#  cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-arm-linux-gnueabihf.cmake
#


# Name of C compiler.
SET(CMAKE_C_COMPILER "arm-uclinuxeabi-gcc")
SET(CMAKE_CXX_COMPILER "arm-uclinuxeabi-g++")


# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
SET(BUILD_SHARED_LIBS OFF)

# where is the target environment 
SET(CMAKE_FIND_ROOT_PATH  ../../../../A2F ../../../../tools ../../../xv-nic)
SET(ZLIB_INCLUDE_DIR "../lzo-2.09/")
SET(ZLIB_LIBRARY "../../lib/libz.a")
SET(OPENSSL_ROOT_DIR "../../ssl")
SET(OPENSSL_LIBRARIES "../../ssl/usr/local/ssl/lib/")
SET(OPENSSL_INCLUDE_DIR "../../ssl/usr/local/ssl/include/openssl/")

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

4) This fails with this complaint 4)此投诉失败

Compiling with SSL support
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: **OPENSSL_LIBRARIES**)
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.5/Modules/FindOpenSSL.cmake:370 (find_package_handle_standard_args)
  CMakeLists.txt:816 (find_package)

Now, what's curious/frustrating is that I do have openssl installed where I claim to; 现在,令我感到好奇/令人沮丧的是,我确实安装了openssl,我声称; further, if I remove 此外,如果我删除

SET(ZLIB_INCLUDE_DIR "../lzo-2.09/")

, I get a complaint similar to the libraries complaint. ,我收到类似图书馆投诉的投诉。 Further, cmake seems to find zlib which is present in a similar way. 此外,cmake似乎找到了以类似方式存在的zlib。 I've compiled several other applications with this ssl setup without trouble, though I'm unfamiliar with cmake in general. 我用这个ssl设置编译了几个其他应用程序没有遇到麻烦,虽然我一般不熟悉cmake。

I've tried to be as verbose as possible without crafting a post too long to read, so if I've left something out, I'd be happy to provide more detail if anyone has fought through this. 我试图尽可能地冗长而没有设置一个帖子太长时间阅读,所以如果我遗漏了一些东西,我很乐意提供更多的细节,如果有人为此而奋斗。 Thanks in advance! 提前致谢!

I had the same issue. 我遇到过同样的问题。 Setting the following variables in my toolchain.cmake file did the trick: 在我的toolchain.cmake文件中设置以下变量就可以了:

SET(ZLIB_INCLUDE_DIR ../../../build/buildroot-build/staging/usr/include)
SET(ZLIB_LIBRARY ../../../build/buildroot-build/target/usr/lib/libz.so)

SET(OPENSSL_ROOT_DIR ../../../build/buildroot-build/target/usr)
SET(OPENSSL_LIBRARIES ../../../build/buildroot-build/target/usr/lib)
SET(OPENSSL_INCLUDE_DIR ../../../build/buildroot-build/staging/usr/include/openssl)
SET(OPENSSL_CRYPTO_LIBRARY ../../../build/buildroot-build/target/usr/lib/libcrypto.so)
SET(OPENSSL_SSL_LIBRARY ../../../build/buildroot-build/target/usr/lib/libssl.so)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM