乐鑫技术交流
直播中

王鹏

7年用户 1336经验值
私信 关注
[问答]

为什么找不到openssl/ssl.h头文件?

Running ninja in directory /home/shihongbo/esp-idf/examples/esp32-lqwy-project-shi/build
Executing "ninja all"...
[1/1] cd /home/shihongbo/esp-idf/examples/esp32-lqwy-project-shi/build/bootloader/esp-idf/esptool_py && /home/shihong...fset 0x8000 bootloader 0x1000 /home/shihongbo/esp-idf/examples/esp32-lqwy-project-shi/build/bootloader/bootloader.bi
Bootloader binary size 0x6860 bytes. 0x7a0 bytes (7%) free.
[2/50] Building C object esp-idf/sta_protocols/CMakeFiles/__idf_sta_protocols.dir/openssl_cilent_node.c.objFAILED: esp-idf/sta_protocols/CMakeFiles/__idf_sta_protocols.dir/openssl_cilent_node.c.obj
/home/shihongbo/.espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -DESP_PLATFORM -DIDF_VER="v5.1-dev-4726-gdf9310ada2-dirty" -DSOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE -D_GNU_SOURCE -D_POSIX_READER_WRITER_LOCKS -Iconfig -I../components/sta_protocols/include -I../../../components/newlib/platform_include -I../../../components/freertos/FreeRTOS-Kernel/include -I../../../components/freertos/FreeRTOS-Kernel/portable/xtensa/include -I../../../components/freertos/esp_additions/include/freertos -I../../../components/freertos/esp_additions/include -I../../../components/freertos/esp_additions/arch/xtensa/include -I../../../components/esp_hw_support/include -I../../../components/esp_hw_support/include/soc -I../../../components/esp_hw_support/include/soc/esp32 -I../../../components/esp_hw_support/port/esp32/. -I../../../components/esp_hw_support/port/esp32/private_include -I../../../components/heap/include -I../../../components/log/include -I../../../components/soc/include -I../../../components/soc/esp32 -I../../../components/soc/esp32/include -I../../../components/hal/esp32/include -I../../../components/hal/include -I../../../components/hal/platform_port/include -I../../../components/esp_rom/include -I../../../components/esp_rom/include/esp32 -I../../../components/esp_rom/esp32 -I../../../components/esp_common/include -I../../../components/esp_system/include -I../../../components/esp_system/port/soc -I../../../components/esp_system/port/include/private -I../../../components/xtensa/include -I../../../components/xtensa/esp32/include -I../../../components/lwip/include -I../../../components/lwip/include/apps -I../../../components/lwip/include/apps/sntp -I../../../components/lwip/lwip/src/include -I../../../components/lwip/port/include -I../../../components/lwip/port/freertos/include -I../../../components/lwip/port/esp32xx/include -I../../../components/lwip/port/esp32xx/include/arch -I../main/include -I../components/remote/include -I../components/port/include -I../components/debug/include -I../../../components/esp_ringbuf/include -I../../../components/esp_wifi/include -I../../../components/esp_wifi/wifi_apps/include -I../../../components/esp_event/include -I../../../components/esp_phy/include -I../../../components/esp_phy/esp32/include -I../../../components/esp_netif/include -I../../../components/driver/include -I../../../components/driver/deprecated -I../../../components/driver/analog_comparator/include -I../../../components/driver/dac/include -I../../../components/driver/gpio/include -I../../../components/driver/gptimer/include -I../../../components/driver/i2c/include -I../../../components/driver/i2s/include -I../../../components/driver/ledc/include -I../../../components/driver/mcpwm/include -I../../../components/driver/parlio/include -I../../../components/driver/pcnt/include -I../../../components/driver/rmt/include -I../../../components/driver/sdio_slave/include -I../../../components/driver/sdmmc/include -I../../../components/driver/sigma_delta/include -I../../../components/driver/spi/include -I../../../components/driver/temperature_sensor/include -I../../../components/driver/touch_sensor/include -I../../../components/driver/twai/include -I../../../components/driver/uart/include -I../../../components/driver/usb_serial_jtag/include -I../../../components/driver/touch_sensor/esp32/include -I../../../components/esp_pm/include -I../components/linux_list/include -I../components/application/include -mlongcalls -Wno-frame-address    -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw -Og -fmacro-prefix-map=/home/shihongbo/esp-idf/examples/esp32-lqwy-project-shi=. -fmacro-prefix-map=/home/shihongbo/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 -std=gnu17 -Wno-old-style-declaration -MD -MT esp-idf/sta_protocols/CMakeFiles/__idf_sta_protocols.dir/openssl_cilent_node.c.obj -MF esp-idf/sta_protocols/CMakeFiles/__idf_sta_protocols.dir/openssl_cilent_node.c.obj.d -o esp-idf/sta_protocols/CMakeFiles/__idf_sta_protocols.dir/openssl_cilent_node.c.obj   -c ../components/sta_protocols/openssl_cilent_node.c
In file included from ../components/sta_protocols/openssl_cilent_node.c:1:
../components/sta_protocols/include/openssl_client_node.h:10:10: fatal error: openssl/ssl.h: No such file or directory
   10 | #include "openssl/ssl.h"
      |          ^~~~~~~~~~~~~~~


目前准备把公司的老esp-idf v4.0构建的esp32工程迁移到v5.1,ubuntu20.04下编译,自己写了CMakeLists,idf.py build后出现找不到头文件openssl/ssl.h头文件,但是我看我的系统根目录下的/usr/include/openssl含有ssl.h,于是添加这个目录到环境变量,为什么还是出现找不到环境变量呢?我的PATH目录中含有usr/include/openssl子目录。为什么还找不到openssl/ssl.h
                                                  

回帖(1)

李勇

2024-6-11 17:06:32
找不到openssl/ssl.h头文件的问题可能是由以下几个原因导致的:

1. **OpenSSL未安装或未正确安装**:确保你的系统中已经安装了OpenSSL库。你可以通过在终端中运行以下命令来检查OpenSSL是否已安装:

   ```bash
   openssl version
   ```

   如果没有安装,你可以使用包管理器来安装它,例如在Ubuntu上:

   ```bash
   sudo apt-get install libssl-dev
   ```

2. **环境变量未设置**:确保你的编译器能够找到OpenSSL的头文件。这通常涉及到设置`C_INCLUDE_PATH`和`CPLUS_INCLUDE_PATH`环境变量。你可以通过在终端中运行以下命令来设置这些变量:

   ```bash
   export C_INCLUDE_PATH=/usr/local/ssl/include:$C_INCLUDE_PATH
   export CPLUS_INCLUDE_PATH=/usr/local/ssl/include:$CPLUS_INCLUDE_PATH
   ```

   注意:这里的`/usr/local/ssl/include`是OpenSSL头文件的路径,根据你的安装情况可能有所不同。

3. **项目配置问题**:检查你的项目配置文件(如Makefile或CMakeLists.txt),确保在编译时包含了OpenSSL的头文件路径。例如,在CMake中,你可以使用`include_directories`命令:

   ```cmake
   include_directories(/usr/local/ssl/include)
   ```

4. **IDE或编辑器设置问题**:如果你使用的是集成开发环境(IDE)或代码编辑器,确保它们也配置了正确的头文件搜索路径。

5. **权限问题**:确保你有权限访问OpenSSL的头文件。如果没有,你可能需要使用`sudo`来安装或修改文件。

6. **路径问题**:有时候,头文件可能在非标准路径下。你可以尝试使用`find`命令来查找`ssl.h`文件:

   ```bash
   sudo find / -name ssl.h
   ```

   如果找到了,确保将该路径添加到你的编译器的头文件搜索路径中。

7. **版本不兼容**:确保你使用的OpenSSL版本与你的项目兼容。有些项目可能需要特定版本的OpenSSL。

8. **依赖问题**:如果你的项目依赖于其他库,确保这些库也正确安装并配置了。

解决这个问题通常需要检查和调整你的系统环境、项目配置和IDE设置。希望这些建议能帮助你找到并解决问题。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分