gpt4 book ai didi

c++ - hello world 在 gcc 5.3.0/bin/ld : invalid option -- 'p' 上失败

转载 作者:行者123 更新时间:2023-11-30 18:12:31 25 4
gpt4 key购买 nike

正确设置 ec2 AMI 编译器的基本问题。

我已经编译了 gcc 5.3.0 并有以下输出

which g++
/home/mybin/bin/g++

g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/tmp/gcc-5.3.0/configure --prefix=/home/mybin/ --enable-languages=c,c++,fortran,go --disable-multilib
Thread model: posix
gcc version 5.3.0 (GCC)

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/tmp/gcc-5.3.0/configure --prefix=/home/mybin/ --enable-languages=c,c++,fortran,go --disable-multilib
Thread model: posix
gcc version 5.3.0 (GCC)

但是当我尝试 hello world /home/myuser/test.c

#include <stdio.h>

int main() {
printf("Hello, world!\n");
return 0;
}

gcc /home/myuser/test.c -o test

返回

/home/mybin/bin/ld: invalid option -- 'p'
Try `ld --help' or `ld --usage' for more information.

感谢@Ismael的指点,我也运行了gcc /home/myuser/test.c -o test但找不到对 --p 的明显引用

gcc -v /home/_cbs/hhvm/test.c -o test
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/tmp/gcc-5.3.0/configure --prefix=/home/mybin/ --enable-languages=c,c++,fortran,go --disable-multilib
Thread model: posix
gcc version 5.3.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mtune=generic' '-march=x86-64'
/home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/cc1 -quiet -v /home/_cbs/hhvm/test.c -quiet -dumpbase test.c -mtune=generic -march=x86-64 -auxbase test -version -o /home/tmp/ccRpAYPt.s
GNU C11 (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 5.3.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include
/usr/local/include
/home/mybin/include
/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed
/usr/include
End of search list.
GNU C11 (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 5.3.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: b4408eaf5114d6109f8b7d1dd0485d10
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mtune=generic' '-march=x86-64'
as -v --64 -o /home/tmp/ccW4b2Db.o /home/tmp/ccRpAYPt.s
GNU assembler version 2.23.52.0.1 (x86_64-amazon-linux) using BFD version version 2.23.52.0.1-55.65.amzn1 20130226
COMPILER_PATH=/home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/:/home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/:/home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/:/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/:/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/:/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mtune=generic' '-march=x86-64'
/home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/collect2 -plugin /home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/liblto_plugin.so -plugin-opt=/home/mybin/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper -plugin-opt=-fresolution=/home/tmp/ccQFq8sT.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/crtbegin.o -L/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0 -L/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../.. /home/tmp/ccW4b2Db.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/crtend.o /usr/lib/../lib64/crtn.o
/home/mybin/bin/ld: invalid option -- 'p'
Try `ld --help' or `ld --usage' for more information.
collect2: error: ld returned 64 exit status

有什么指示可以指出我的配置有什么问题吗?

感谢艺术。

最佳答案

我认为发生此错误是因为外部源错误,而不是内部源错误。

根据我的经验,使用 3ways 来修复。

方法一。重新安装 Visual Studio

方式2。1.复制源。2.删除当前项目。3.创建新项目并粘贴该源代码。

方式3。在 macOS 中使用 xcode。

关于c++ - hello world 在 gcc 5.3.0/bin/ld : invalid option -- 'p' 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34817552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com