此文章并未获得最终成功,供大家参考
参考地址:https://www.cnblogs.com/orangezs/p/8453610.html
硬件:极路由1S h5661
已经刷入openwrt 21.02.1
本地openwrt sdk地址:/home/devuser/CLionProjects/openwrt-sdk-21.02.1/dl/cmake-3.9.6
编译套件地址:/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/
经过测试发现,openwrt 21.02.2 sdk不能支持c++11,只支持cmake3.9.6
下载cmake 3.9.6到本地目录/home/devuser/CLionProjects/openwrt-sdk-21.02.1/dl/并解压到
/home/devuser/CLionProjects/openwrt-sdk-21.02.1/dl/cmake-3.9.6
修改CMakeList.txt,添加以下内容:
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") SET(CMAKE_C_COMPILER "/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/mipsel-openwrt-linux-musl-gcc") SET(CMAKE_CXX_COMPILER "/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/mipsel-openwrt-linux-musl-g++") SET(CMAKE_AR "/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/mipsel-openwrt-linux-musl-ar") SET(CMAKE_LINKER "/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/mipsel-openwrt-linux-musl-ld") SET(CMAKE_RANLIB "/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/mipsel-openwrt-linux-ranlib") SET(CMAKE_NM "/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/mipsel-openwrt-linux-nm") SET(CMAKE_OBJDUMP "/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/mipsel-openwrt-linux-objdump") SET(CMAKE_OBJCOPY "/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/mipsel-openwrt-linux-objcopy") SET(CMAKE_STRIP "/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/mipsel-openwrt-linux-strip") #以下为源文件内容 cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR)
1、使用clion通过CMakeList.txt生成Makefile或者修改~/.bashrc设置/home/devuser/CLionProjects/openwrt-sdk-21.02.1/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/到PATH路径编译
编译过程中报错;缺少opensslconf.h
解决方法:下载openssl-1.1.1m,在openssl目录执行以下命令
./config make
2、将openssl-1.1.1m/include/openssl目录中文件全部拷贝到 cmake-3.9.6/Utilities/openssl/
3、将cmake-3.9.6/Utilities/openssl-1.1.1m/ssl/目录中文件全部拷贝到 cmake-3.9.6/Utilities/openssl/
4、第1步执行后会获得Makefile,然后执行
make
再往下不懂怎么解决了。
本文章适合人群:
懂cmake,c语言开发,linux基本make命令等