Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ hello world在gcc 5.3.0/bin/ld上失败:无效选项--“p”_C++_C_Gcc - Fatal编程技术网

C++ hello world在gcc 5.3.0/bin/ld上失败:无效选项--“p”

C++ hello world在gcc 5.3.0/bin/ld上失败:无效选项--“p”,c++,c,gcc,C++,C,Gcc,正确设置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

正确设置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)
但是,当我尝试helloworld/home/myuser/test.c时

感谢@Ismael提供的指针,我还运行了gcc/home/myuser/test.c-o测试,但找不到对-p的明显引用

有没有指向我配置中出错的地方的指针


thx Art.

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

根据我的经验, 使用3种方法修复

方式一。 重新安装visual studio

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

路3。
在mac os中使用xcode。

为什么系统的/home/中有一个C文件?或者你的意思是/home/Username/test.c?你也尝试过更新/重新编译ld吗?Gcc有一个-v选项,显示它是如何调用其他命令的。@Ismael,用Gcc-v更新,看起来和g++-v一样,我看不到-p选项的迹象see@Rolbrok,不,我没有重新编译它,在哪里可以找到源存储库?我看了看下面https://www.gnu.org/software/binutils/ 但我无法确定这是否是正确的存储库??
#include <stdio.h>

int main() {
    printf("Hello, world!\n");
    return 0;
}
/home/mybin/bin/ld: invalid option -- 'p'
Try `ld --help' or `ld --usage' for more information.
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