我使用 cygwin 为我的平台构建 binutils。我遵循了GCC-Cross-Compiler文章并堆栈了“make”命令。我使用的命令:
export PREFIX="$HOME/opt/cross"
../binutils-2.42/configure --target=amd64 --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make CFLAGS="-march=x86-64-v2" && make install
在“make”命令上它抛出了以下错误:
../../binutils-2.42/libiberty/pex-unix.c:259:14: warning: implicit declaration of function ‘wait’; did you mean ‘cwait’? [-Wimplicit-function-declaration]
259 | cpid = wait (status);
| ^~~~
| cwait
../../binutils-2.42/libiberty/pex-unix.c: In function ‘save_and_install_fd’:
../../binutils-2.42/libiberty/pex-unix.c:385:11: warning: implicit declaration of function ‘fcntl’ [-Wimplicit-function-declaration]
385 | flags = fcntl (old_fd, F_GETFD);
| ^~~~~
../../binutils-2.42/libiberty/pex-unix.c:385:26: error: ‘F_GETFD’ undeclared (first use in this function)
385 | flags = fcntl (old_fd, F_GETFD);
| ^~~~~~~
../../binutils-2.42/libiberty/pex-unix.c:385:26: note: each undeclared identifier is reported only once for each function it appears in
../../binutils-2.42/libiberty/pex-unix.c:398:20: error: ‘FD_CLOEXEC’ undeclared (first use in this function)
398 | if ((flags & FD_CLOEXEC) == 0 && fcntl (old_fd, F_SETFD, FD_CLOEXEC) < 0)
| ^~~~~~~~~~
../../binutils-2.42/libiberty/pex-unix.c:398:55: error: ‘F_SETFD’ undeclared (first use in this function)
398 | if ((flags & FD_CLOEXEC) == 0 && fcntl (old_fd, F_SETFD, FD_CLOEXEC) < 0)
| ^~~~~~~
../../binutils-2.42/libiberty/pex-unix.c:411:31: error: ‘F_DUPFD’ undeclared (first use in this function)
411 | new_fd = fcntl (old_fd, F_DUPFD, 3);
| ^~~~~~~
../../binutils-2.42/libiberty/pex-unix.c: In function ‘restore_fd’:
../../binutils-2.42/libiberty/pex-unix.c:445:19: error: ‘FD_CLOEXEC’ undeclared (first use in this function)
445 | if (flags & FD_CLOEXEC)
| ^~~~~~~~~~
../../binutils-2.42/libiberty/pex-unix.c:447:29: error: ‘F_SETFD’ undeclared (first use in this function)
447 | return fcntl (old_fd, F_SETFD, flags);
(还有很多,但我认为没有意义全部放完)
尝试调整编译标志,尝试不删除 -march=x86_64-v2 规范。
我不知道你是否解决了这个问题,我意识到我的Windows已经安装了另一个版本的mingw gcc并设置了环境变量,所以我删除了mingw的环境变量,并从cygwin安装程序中安装了gcc-g++,然后它成功了!希望这对您有帮助!