无法为OpenWRT编译C 上的helloworld
Cannot compile package Helloworld on C++ for OpenWrt
我正在尝试为OpenWrt编译简单的Helloworld程序(使用Build System,分支17.01.6)。我使用了两个教程:官方网站上的Helloworld教程和埃里克·毕晓普(Eric Bishop),第2部分for C 。
但是在编译Helloworld包装期间,我有错误:Package helloworld is missing dependencies for the following libraries:
libc.so.6
文件的结构:
。
├-openwrt_17_01
    nbsp; source #source目录,构建系统
   ├-helloworld #helloworld project
     |     |     |   nbsp; nbsp;└--mypackages
"      nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nblowerld
       nbsp; nbsp; nbsp;    nbsp; nbsp; nbsp; nbsp;    
OpenWrt_17_01/helloworld/src/helloworld.cpp:
#include "stdio.h"
int main()
{
printf("Hello, world! (C++)nn");
return 0;
}
OpenWrt_17_01/helloworld/src/makefile:
helloworld: helloworld.o
$(CXX) $(LDFLAGS) helloworld.o -o helloworld $(LIBS)
helloworld.o: helloworld.cpp
$(CXX) $(CXXFLAGS) -c helloworld.cpp
clean:
rm *.o helloworld
mypackages/示例/helloworld/makefile:
include $(TOPDIR)/rules.mk
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1
SOURCE_DIR:=/home/mzhi/proj_src/openwrt_17_01/helloworld
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/helloworld
SECTION:=examples
DEPENDS:= +libstdcpp +libc
CATEGORY:=Examples
TITLE:=Hello, World!
endef
define Package/helloworld/description
A simple "Hello, world!" -application.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) $(SOURCE_DIR)/src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)
LIBS="-nodefaultlibs -lgcc -lc -luClibc++"
LDFLAGS="$(EXTRA_LDFLAGS)"
CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) -nostdinc++"
$(TARGET_CONFIGURE_OPTS)
CROSS="$(TARGET_CROSS)"
ARCH="$(ARCH)"
$(1);
endef
define Package/helloworld/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
endef
$(eval $(call BuildPackage,helloworld))
汇编的全部输出(制作包/helloworld/compile -j1 v = s):
make[1]: Entering directory
'/home/mzhi/proj_src/openwrt_17_01/openwrt'
make[2]: Entering directory
'/home/mzhi/proj_src/openwrt_17_01/openwrt/package/libs/toolchain'
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target- mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
echo "libc" >>
/home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
echo "libgcc" >>
/home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
echo "libstdcpp" >>
/home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
echo "libpthread" >>
/home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
echo "librt" >>
/home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
make[2]: Leaving directory '/home/mzhi/proj_src/openwrt_17_01/openwrt/package/libs/toolchain'
make[2]: Entering directory '/home/mzhi/proj_src/openwrt_17_01/mypackages/examples/helloworld'
mkdir -p /home/mzhi/proj_src/openwrt_17_01/openwrt/bin/targets/ramips/mt7621/packages /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/ipkg-mipsel_24kc/helloworld/CONTROL /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo
install -d -m0755 /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/ipkg-mipsel_24kc/helloworld/usr/bin
install -m0755 /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/helloworld /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/ipkg-mipsel_24kc/helloworld/usr/bin
find /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/ipkg-mipsel_24kc/helloworld -name 'CVS' -o -name '.svn' -o -name '.#*' -o -name '*~'| xargs -r rm -rf
Package helloworld is missing dependencies for the following libraries:
libc.so.6
Makefile:65: recipe for target '/home/mzhi/proj_src/openwrt_17_01/openwrt/bin/packages/mipsel_24kc/mypackages/helloworld_1.0-1_mipsel_24kc.ipk' failed
make[2]: *** [/home/mzhi/proj_src/openwrt_17_01/openwrt/bin/packages/mipsel_24kc/mypackages/helloworld_1.0-1_mipsel_24kc.ipk] Error 1
make[2]: Leaving directory '/home/mzhi/proj_src/openwrt_17_01/mypackages/examples/helloworld'
package/Makefile:105: recipe for target 'package/feeds/mypackages/helloworld/compile' failed
make[1]: *** [package/feeds/mypackages/helloworld/compile] Error 2
make[1]: Leaving directory '/home/mzhi/proj_src/openwrt_17_01/openwrt'
/home/mzhi/proj_src/openwrt_17_01/openwrt/include/toplevel.mk:205: recipe for target 'package/helloworld/compile' failed
make: *** [package/helloworld/compile] Error 2
操作系统:Ubuntu 16.04
目标系统:Mediatek Ralink Mips
子目标:基于MT7621的董事会
目标配置文件:ubiquiti edgerouter x
谷歌搜索了很多,但是我仍然不明白为什么编译器看不到必要的库libc.so..6以及如何在makefile
中正确连接它也许有人已经面临类似的问题,请分享解决方案。
如何将您的Makefile更改为此?
BINARY = helloworld$(EXE)
FILES = helloworld.o
all: $(BINARY)
helloworld$(EXE): $(FILES)
$(CC) $(FILES) -o $(@)
clean:
rm -f $(FILES) *.o
和该代码:
#include <stdio.h>
int main()
{
printf("Hello, world! (C++)nn");
return 0;
}
您想要的答案在这里:https://fleshandmachines.wordpress.com/2011/08/22/openwrt-cc-programing/
您必须更改$(CXX)
的$(CC)
和$(CXXFLAGS)
$(CFLAGS)
- Linux的Cpp上的计时器
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 物理键盘上的触发器按键
- 如何加载(或映射)文件部分的最大大小,但适合在Windows上的RAM
- SSL上的`curl_easy_send`和`curl_asy_recv`:如何处理`CURLE_AGAIN`
- PowerPC ppc64le上的Gcc Woverloaded虚拟错误
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- 集合上的输出迭代器:assign和increment迭代器
- Cuda C++:设备上的Malloc类,并用来自主机的数据填充它
- 为什么我在leetcode上收到AddressSanitizer:地址0x602000000058上的堆缓冲区溢出错误
- 对于set上的循环-获取next元素迭代器
- 如何从棋盘上的箱号中找到行和列
- 为什么除非添加括号,否则构造函数上的模板替换会失败?
- if数组上的随机数
- 向量上的线性搜索
- 位阵列上的快速AND运算
- 无法将 GLFW 库与 Ubuntu 18.04 上的头文件链接
- 为什么一个向量上的多线程操作很慢
- 无法为OpenWRT编译C 上的helloworld
- Visual Studio 2008 上的 HelloWorld OpenGL 程序中未处理的异常错误