我正在尝试使用openwrt编译Helloworld for Raspberry Pi 3B。
Helloworld.c
#include <stdio.h>
int main(void)
{
printf("Hell! O' world, why won't my code compile?\n\n");
return 0;
}
生成文件
# build helloworld executable when user executes "make"
helloworld: helloworld.o
$(CC) $(LDFLAGS) helloworld.o -o helloworld
helloworld.o: helloworld.c
$(CC) $(CFLAGS) -c helloworld.c
# remove object files and executable when user executes "make clean"
clean:
rm *.o helloworld
我通过ssh上传到raspberry。当我执行helloworld时,我得到了这个回复
root@LEDE:~# ./helloworld
./helloworld: line 1: syntax error: unexpected word (expecting ")")
当我使用本指南https://manoftoday.wordpress.com/2007/10/11/writing-and-compiling-a-simple-program-for-openwrt/时,我在使用makefile后得到了这个
user@debian:~/OpenWrt-SDK-Linux-i686-1$ make V=99
make package/compile
make[1]: Entering directory «/home/user/OpenWrt-SDK-Linux-i686-1»
Collecting package info...
make -C package compile SDK=1
make[2]: Entering directory «/home/user/OpenWrt-SDK-Linux-i686-1/package»
Makefile:3: /home/user/OpenWrt-SDK-Linux-i686-1/.pkgdeps: No such file or directory
/home/user/OpenWrt-SDK-Linux-i686-1/include/host.mk:8: /home/user/OpenWrt-SDK-Linux-i686-1/tmp/.host.mk: No such file or directory
--: /home/user/OpenWrt-SDK-Linux-i686-1/include/shell.sh;: No such file or directory
--: /home/user/OpenWrt-SDK-Linux-i686-1/include/shell.sh;: No such file or directory
/home/user/OpenWrt-SDK-Linux-i686-1/include/host.mk:13: failed to perform the recipe for the target «/home/user/OpenWrt-SDK-Linux-i686-1/tmp/.host.mk»
make[2]: *** [/home/user/OpenWrt-SDK-Linux-i686-1/tmp/.host.mk] Error 1
make[2]: Exit from directory «/home/user/OpenWrt-SDK-Linux-i686-1/package»
Makefile:48: failed to perform the recipe for the target «package/compile»
make[1]: *** [package/compile] Error 2
make[1]: Exit from directory «/home/user/OpenWrt-SDK-Linux-i686-1»
Makefile:54: failed to perform the recipe for the target «world»
make: *** [world] Error 2
我做错了什么?如何解决?
答案 0 :(得分:0)
手臂和x86问题?
听我说,使用“ opkg install make gcc”将make和gcc安装到Openwrt中
然后在Openwrt上构建您的项目,做得很好。
您的问题来自哪里?这是由平台差异引起的。
因此,如果您始终想在x86平台上构建它,请使用交叉编译器。