In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to write a C++ program and make it into an ipk package". The content in the article is simple and clear, and it is easy to learn and understand. Now please follow the editor's train of thought slowly and deeply, to study and learn "how to write a C++ program and make it into an ipk package" bar.
Contents of each file
Create a cpp-demo directory under the SDK/package/ path and generate a very simple cpp program
$cd SDK$ mkdir-p package/cpp-demo$ cd package/cpp-demo$ touch Makefile$ mkdir src$ cd src$ touch Makefile main.cpp
Form the following directory structure:
$tree package/demo-cpppackage/cpp-demo/ |-- Makefile`-- src |-- main.cpp `--Makefile
Package/cpp-demo/src/main.cpp content:
# include using namespace std;int main (int argc, char * * argv) {cout
Delete the SDK/build_dir and re-make. In order to facilitate analysis
$rm-rf build_dir$ make VIPs | less
Analyze the printed information:
CC= "mips-openwrt-linux-uclibc-gcc" GCC= "mips-openwrt-linux-uclibc-gcc" CXX= "mips-openwrt-linux-uclibc-g++"... make [4]: Entering directory `/ home/hevake_lcj/Workspace/OpenWRT/OpenWrt-SDK/build_dir/target-mips_34kc_uClibc-0.9.33.2/cpp-demo'make [4]: Nothing to be done for `ALL'.make [4]: Leaving directory` / home/hevake_lcj/Workspace/OpenWRT/OpenWrt- SDK/build_dir/target-mips_34kc_uClibc-0.9.33.2/cpp-demo'...
Huh? Nothing to be done for 'ALL', indicates that there is nothing more to compile.
I hastened to check
[SDK] $ls build_dir/target-mips_34kc_uClibc-0.9.33.2/cpp-demo/cpp-demo ipkg-ar71xx main.cpp main.o Makefile
It is found that cpp-demo has been generated and can be run on the development machine. How did this cpp-demo come from? Can you tell if it comes from package/cpp-demo/src?
It suddenly occurred to me that I had entered the package/cpp-demo/src/ path and executed make once, and I must have generated a cpp-demo executable program at that time. View it:
[SDK] $ls package/cpp-demo/src/cpp-demo main.cpp main.o Makefile
There is it! In make, because of its existence, the compiler component thinks that it is no longer necessary to compile, which leads to the above problems.
Delete cpp-demo and main.o. Go back to SDK and re-make
$rm-rf build_dir$ make VIPs | less
Analyze the printed information:
CC= "mips-openwrt-linux-uclibc-gcc" GCC= "mips-openwrt-linux-uclibc-gcc" CXX= "mips-openwrt-linux-uclibc-g++"... make [4]: Entering directory `/ home/hevake_lcj/Workspace/OpenWRT/OpenWrt-SDK/build_dir/target-mips_34kc_uClibc-0.9.33.2/cpp-demo'mips-openwrt-linux-uclibc-g++-Os-pipe-mno-branch-likely-mips32r2-mtune=34kc-fno-caller-saves-fhonour-copts- Wno-error=unused-but-set-variable\-msoft-float-mips16-minterlink-mips16-I/home/hevake_lcj/Workspace/OpenWRT/OpenWrt-SDK/staging_dir/target-mips_34kc_uClibc-0.9.33.2/usr/include\-I/home/hevake_lcj/Workspace/OpenWRT/OpenWrt-SDK/staging_dir/target-mips_34kc_uClibc-0.9.33.2/include\-I/home/hevake_lcj/Workspace/OpenWRT/OpenWrt-SDK / staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/include\-I/home/hevake_lcj/Workspace/OpenWRT/OpenWrt-SDK/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/include\-c-o main.o main.cppecho "DEBUG: CXX = mips-openwrt-linux-uclibc-g++" DEBUG: CXX = mips-openwrt-linux-uclibc-g++mips -openwrt-linux-uclibc-g++-o cpp-demo main.omake [4]: Leaving directory `/ home/hevake_lcj/Workspace/OpenWRT/OpenWrt-SDK/build_dir/target-mips_34kc_uClibc-0.9.33.2/cpp-demo'...
According to the debugging information, you can know that cpp-demo is compiled with mips-openwrt-linux-uclibs-g++. This should be right!
Try to transfer the ipk file to the target machine again and install it. The running effect is as follows:
Root@OpenWrt:~# cpp-demo This is C++ Demo
Succeed!
Thank you for your reading, the above is the content of "how to write the C++ program and make it into an ipk package". After the study of this article, I believe you have a deeper understanding of how to write the C++ program and make it into an ipk package, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.