如何使用NetBSD构建交叉编译NetBSD工具链

时间:2015-11-28 22:43:21

标签: c gcc4 netbsd

我有一个使用qemu创建的NetBSD VM,我正在尝试使用我使用NetBSD源附带的Hello World.c脚本构建的交叉编译工具链编译一个简单的build.sh程序。但是,我无法编译程序。

我使用以下命令构建了工具链,

./build.sh -m evbarm tools

./build.sh -m evbarm -U distribution

上述命令的输出结果为

===> Tools built to /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386
===> build.sh ended:   Sat Nov 28 12:52:34 CST 2015
===> Summary of results:
         build.sh command: ./build.sh -m evbarm tools
         build.sh started: Sat Nov 28 12:48:47 CST 2015
         NetBSD version:   4.0
         MACHINE:          evbarm
         MACHINE_ARCH:     arm
         Build platform:   NetBSD 4.0.1 i386
         HOST_SH:          /bin/sh
         No nonexistent/bin/nbmake, needs building.
         Bootstrapping nbmake
         TOOLDIR path:     /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386
         DESTDIR path:     /opt/cross/evbarm/usr/src/destdir.evbarm
         RELEASEDIR path:  /opt/cross/evbarm/usr/src/releasedir
         Created /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386/bin/nbmake
         makewrapper:      /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386/bin/nbmake-evbarm
         Updated /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386/bin/nbmake-evbarm
         Tools built to /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386
         build.sh ended:   Sat Nov 28 12:52:34 CST 2015
===> .


make distribution started at:  Sat Nov 28 14:31:23 CST 2015
make distribution finished at: Sat Nov 28 15:04:34 CST 2015
===> Successful make distribution
===> build.sh ended:   Sat Nov 28 15:04:34 CST 2015
===> Summary of results:
         build.sh command: ./build.sh -m evbarm -U distribution
         build.sh started: Sat Nov 28 14:31:20 CST 2015
         NetBSD version:   4.0
         MACHINE:          evbarm
         MACHINE_ARCH:     arm
         Build platform:   NetBSD 4.0.1 i386
         HOST_SH:          /bin/sh
         No nonexistent/bin/nbmake, needs building.
         Bootstrapping nbmake
         TOOLDIR path:     /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386
         DESTDIR path:     /opt/cross/evbarm/usr/src/destdir.evbarm
         RELEASEDIR path:  /opt/cross/evbarm/usr/src/releasedir
         Created /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386/bin/nbmake
         makewrapper:      /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386/bin/nbmake-evbarm
         Updated /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386/bin/nbmake-evbarm
         Successful make distribution
         build.sh ended:   Sat Nov 28 15:04:34 CST 2015
===> .

但是,当我尝试使用helloARM.c包装器编译nbmake-evbarm时,我得到以下输出,

$ nbmake-evbarm ./helloARM
/opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386/bin/arm--netbsdelf-gcc -O2   -Werror    -nostdinc -isystem /opt/cross/evbarm/usr/src/destdir.evbarm/usr/include    -o ./helloARM ./helloARM.c 
/opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386/lib/gcc/arm--netbsdelf/4.1.2/../../../../arm--netbsdelf/bin/ld: crt0.o: No such file: No such file or directory
collect2: ld returned 1 exit status

*** Failed target:  ./helloARM
*** Failed command: /opt/cross/evbarm/usr/src/tooldir.NetBSD-4.0.1-i386/bin/arm--netbsdelf-gcc -O2 -Werror -nostdinc -isystem /opt/cross/evbarm/usr/src/destdir.evbarm/usr/include -o ./helloARM ./helloARM.c 
*** Error code 1

Stop.
nbmake: stopped in /home/capin/apps

1 个答案:

答案 0 :(得分:2)

不要将./路径前缀放在目标名称上。

即。刚跑:

nbmake-evbarm helloARM

我当然假设您在同一目录中有一个Makefile,看起来有点像这样,至少:

PROG = helloARM

.include <bsd.prog.mk>

您必须拥有使用标准NetBSD宏的本地Makefile,因为当没有makefile时(或当makefile不使用正确的NetBSD宏,即<bsd.prog.mk>)时,默认为{{使用1}}宏,它们不包括访问目标系统的标头和库等所需的所有sys.mk魔法。