Ubuntu下为openwrt交叉编译cmake

此文章并未获得最终成功,供大家参考

参考地址: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

Ubuntu下为openwrt交叉编译cmake

再往下不懂怎么解决了。

本文章适合人群:

懂cmake,c语言开发,linux基本make命令等

原文链接: https://www.cnblogs.com/passedbylove/p/15755163.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/182799

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 上午10:17
下一篇 2023年2月12日 上午10:18

相关推荐