Compilation g++链接器选项更改目标文件名

Compilation g++链接器选项更改目标文件名,compilation,linker,g++,Compilation,Linker,G++,我需要帮助它是错误还是我不明白编译选项是如何工作的? 我有一个示例main.c文件,并尝试将其编译为: $ g++ -nostdlib -g -fno-rtti -fno-exceptions -ffreestanding -nostdinc -nostdinc++ -Wl,--build-id=none,-g,-nostdlib,-nostartfiles,-zmax-page-size=0x1000 main.c -o main 作为输出,我有: $ ls main.c startfil

我需要帮助它是错误还是我不明白编译选项是如何工作的? 我有一个示例main.c文件,并尝试将其编译为:

$ g++ -nostdlib -g -fno-rtti -fno-exceptions -ffreestanding -nostdinc -nostdinc++ -Wl,--build-id=none,-g,-nostdlib,-nostartfiles,-zmax-page-size=0x1000 main.c -o main
作为输出,我有:

$ ls
main.c  startfiles
我试图理解为什么g++创建的名为startfiles的文件不是main?

如果您阅读了,您将看到没有名为-nostartfiles的选项。将参数传递给链接器的是选项-n和-ostartfiles

如果我是你,我会检查你试图传递给链接器的其他选项。

-nostartfiles是一个编译器标志,据我所知,不是链接器标志

对于链接器,它与-n-o startfiles相同,这就是为什么要获得输出文件名